Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

If particular condition is not satisfied in case how to say that to be zero

$
0
0

select sal, case when sal < 2000 then 'category 1'
when sal < 3000 then 'category 2'
when sal < 4000 then 'category 3'
else 'category 4'
end
from emp;

In the query above how to say Category 1 = 0 when there are no employees with salary less than 2000


Viewing all articles
Browse latest Browse all 7129

Trending Articles