怎么在CASE WHEN 语句里加两个重复的字段
例如:两个STATUS字段
"SELECT CASE WHEN STATUS = 0 THEN '通过' WHEN STATUS = 1 THEN '未通过' WHEN STATUS = 2 THEN '审核中' END STATUS,CASE WHEN PRI = 0 THEN '最高' WHEN PRI = 1 THEN '普通' END PRI,STATUS = 0 THEN '已审核' WHEN STATUS = 1 THEN '已审核' WHEN STATUS = 2 THEN '未通过' END STATUS,USER_ID,TO_CHAR(SEND_TIME,'YYYY-MM-DD HH24:MI:SS') SEND_TIME,TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME FROM TEL_SMS_CONTENT WHERE ID=?
但是不好使 , 求大神指导
------解决方案--------------------
SELECT CASE
WHEN STATUS = 0 THEN
'通过'
WHEN STATUS = 1 THEN
'未通过'
WHEN STATUS = 2 THEN
'审核中'
END STATUS,
CASE
WHEN PRI = 0 THEN
'最高'
WHEN PRI = 1 THEN
'普通'
END PRI,
case
when STATUS = 0 THEN
'已审核'
WHEN STATUS = 1 THEN
'已审核'
WHEN STATUS = 2 THEN
'未通过'
END STATUS,
USER_ID,
TO_CHAR(SEND_TIME, 'YYYY-MM-DD HH24:MI:SS') SEND_TIME,
TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME
FROM TEL_SMS_CONTENT
WHERE ID = ?
发code的时候把code格式化一下嘛,让帮你的人能够轻松些