Reputation: 583
I need to have an other value instead of FULL and NONE but I must do it in the 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
Can I do this with an as anyhow?
Upvotes: 0
Views: 47
Reputation: 225
Here is what you want:
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
Upvotes: 2
Reputation: 18737
Problem:
You should use ()
when you have multiple conditions in WHERE
clause.
Solution:
Improved your query with IN
. You can use any other values inside the ()
:
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
Upvotes: 0