Site: LeetCode
Difficulty per Site: Medium
Write a solution to calculate the number of bank accounts for each salary category. [Full Description]
-- Submitted Solution
SELECT
"Low Salary" AS category
,IFNULL(COUNT(account_id), 0) AS accounts_count
FROM Accounts
WHERE income < 20000
UNION
SELECT
"Average Salary" AS category
,IFNULL(COUNT(account_id), 0) AS accounts_count
FROM Accounts
WHERE income >= 20000 AND income <= 50000
UNION
SELECT
"High Salary" AS category
,IFNULL(COUNT(account_id), 0) AS accounts_count
FROM Accounts
WHERE income > 50000
;
-- LeetCode Solution
-- TBD
TBD
IFNULL