-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Time: 2005 ms (19.75%), Space: 0B (100.00%) - LeetHub
- Loading branch information
1 parent
6b1ab3c
commit 3b50b51
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
1907-count-salary-categories/1907-count-salary-categories.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Write your MySQL query statement below | ||
|
||
SELECT category, COUNT(*) - 1 AS accounts_count | ||
FROM | ||
(SELECT | ||
CASE | ||
WHEN income > 50000 THEN "High Salary" | ||
WHEN income >= 20000 AND income <= 50000 THEN "Average Salary" | ||
ELSE "Low Salary" | ||
END AS category | ||
FROM Accounts | ||
UNION ALL | ||
SELECT * | ||
FROM (VALUES ROW("Low Salary"), ROW("Average Salary"), ROW("High Salary")) AccountsCategories (category)) AccountsCategoriesCount | ||
GROUP BY category |