Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 924 Bytes

129_count_salary_categories.md

File metadata and controls

52 lines (39 loc) · 924 Bytes

SQL Everyday #129

Count Salary Categories

Site: LeetCode
Difficulty per Site: Medium

Problem

Write a solution to calculate the number of bank accounts for each salary category. [Full Description]

Submitted Solution

-- 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
;

Site Solution

-- LeetCode Solution 
-- TBD

Notes

TBD

NB

IFNULL

Go to Index
Go to Overview