Skip to content

Commit

Permalink
Time: 2005 ms (19.75%), Space: 0B (100.00%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
joseantoniochacon committed Sep 30, 2024
1 parent 6b1ab3c commit 3b50b51
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions 1907-count-salary-categories/1907-count-salary-categories.sql
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

0 comments on commit 3b50b51

Please sign in to comment.