我需要有一个其他值而不是FULL和NONE,但我必须在select中执行。
SELECT Calendar_Month,Series,Cnt
FROM T_Cust_Eom_n
where TYP='REB'
and Series='FULL'
or TYP='REB'
and Series='NONE'
order by Series desc,Calendar_Month
无论如何我可以这样做吗?
答案 0 :(得分:2)
这是你想要的:
SELECT Calendar_Month,
CASE WHEN Series = 'FULL'
THEN 'YOUR_TEXT_FOR_FULL'
WHEN Series = 'NONE'
THEN 'YOUR_TEXT_FOR_NONE'
END
AS Series
,Cnt
FROM T_Cust_Eom_n
WHERE (TYP='REB'and Series='FULL') OR (TYP='REB' and Series='NONE') ORDER BY Series DESC,Calendar_Month
答案 1 :(得分:0)
<强>问题:强>
如果()
子句中有多个条件,则应使用WHERE
。
<强>解决方案:强>
使用IN
改进了您的查询。您可以使用()
中的任何其他值:
SELECT Calendar_Month,Series,Cnt
FROM T_Cust_Eom_n
where TYP='REB'
and Series IN ('FULL','NONE', 'ANOTHER_VALUE')
order by Series desc,Calendar_Month