Skip to content

Commit c687c0f

Browse files
committed
'case' in sql
1 parent 3133219 commit c687c0f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

conditional case.sql

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
case - start the condition
2+
when (constraint)
3+
then -> execution
4+
else -> if not above all condition
5+
end -
6+
7+
select username, case
8+
when rating between 1000 and 1199 then '4 star rated'
9+
when rating betweem 1200 and 1399 then '5 star rated'
10+
when rating between 1400 and 1599 then '6 star rated'
11+
else 'Not a coder.'
12+
end as category
13+
from CODECHEF;

0 commit comments

Comments
 (0)