File tree 1 file changed +6
-10
lines changed
src/main/kotlin/g1901_2000/s1907_count_salary_categories
1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change 1
1
# Write your MySQL query statement below
2
- # #Medium #Database #2023_06_22_Time_2358_ms_(73.89%)_Space_0B_(100.00%)
3
- with cte1 as (SELECT ' Low Salary' AS category,SUM (CASE WHEN INCOME< 20000 THEN 1 ELSE 0 END ) AS accounts_count from Accounts),
4
- cte2 as (SELECT ' Average Salary' AS category,SUM (CASE WHEN INCOME BETWEEN 20000 AND 50000 THEN 1 ELSE 0 END ) AS accounts_count from Accounts),
5
- cte3 as (SELECT ' High Salary' AS category,SUM (CASE WHEN INCOME> 50000 THEN 1 ELSE 0 END) AS accounts_count
6
- FROM Accounts)
7
- SELECT * from cte3
8
- UNION ALL
9
- SELECT * FROM cte1
10
- UNION ALL
11
- SELECT * FROM cte2
2
+ # #Medium #Database #2023_08_17_Time_2283_ms_(89.29%)_Space_0B_(100.00%)
3
+ select ' Low Salary' as category, count (* ) as accounts_count from accounts where income< 20000
4
+ union
5
+ select ' Average Salary' as category, count (* ) as accounts_count from accounts where income>= 20000 and income<= 50000
6
+ union
7
+ select ' High Salary' as category, count (* ) as accounts_count from accounts where income> 50000
You can’t perform that action at this time.
0 commit comments