MySql中case when then 的使用

select "主键",  "项目编号", "项目名称","项目创建时间", "项目状态","部门名称","创建人"

union

(select
	pp.id as "主键",
	pp.project_number as "项目编号",  
	pp.name as "项目名称",
	pp.create_time as "项目创建时间",
	
	CASE WHEN pp.status = 'N' THEN '新建'
	WHEN pp.status = 'T' THEN '提测'
	WHEN pp.status = 'W' THEN '审核通过'
	WHEN pp.status = 'QAS' THEN '等待上线'
	WHEN pp.status = 'H' then '进行中'
	END as "项目状态",

	ppd.name as "部门名称",
	pu.login_name as "创建人"
from pmp_project pp
left join pmp_user pu on pp.create_user_id = pu.id
left join pmp_project_dept ppd on pp.project_line_id = ppd.id 
where pp.status != 'C'
order by s.id)

 

你可能感兴趣的:(casewhenthenend)