Skip to content

Commit 70cd2cb

Browse files
authored
Update 36-01907-count-salary-categories.sql
1 parent bea84c5 commit 70cd2cb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

36-01907-count-salary-categories.sql

+17
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1+
-- since all rows are supposed to have different texts, use UNION
2+
-- count rows for each income group
13

4+
select 'Low Salary' as category, sum(case when income < 20000 then 1 else 0 end) as accounts_count
5+
from Accounts
6+
7+
union
8+
9+
select 'Average Salary' as category, sum(case when income between 20000 and 50000 then 1 else 0 end) as accounts_count
10+
from Accounts
11+
12+
union
13+
14+
select 'High Salary' as category, sum(case when income > 50000 then 1 else 0 end) as accounts_count
15+
from Accounts
16+
17+
18+
-- no companies listed

0 commit comments

Comments
 (0)