Content-Length: 316271 | pFad | http://github.com/iamAntimPal/LeetCode_SQL_Database/discussions/22

B9 LeetCode SQL 50 · iamAntimPal LeetCode_SQL_Database · Discussion #22 · GitHub
Skip to content

LeetCode SQL 50 #22

Answered by iamAntimPal
IamShiwangi asked this question in Q&A
Mar 21, 2025 · 2 comments · 1 reply
Discussion options

You must be logged in to vote
# Write your MySQL query statement below
WITH
    S AS (
        SELECT 'Low Salary' AS category
        UNION
        SELECT 'Average Salary'
        UNION
        SELECT 'High Salary'
    ),
    T AS (
        SELECT
            CASE
                WHEN income < 20000 THEN "Low Salary"
                WHEN income > 50000 THEN 'High Salary'
                ELSE 'Average Salary'
            END AS category,
            COUNT(1) AS accounts_count
        FROM Accounts
        GROUP BY 1
    )
SELECT category, IFNULL(accounts_count, 0) AS accounts_count
FROM
    S
    LEFT JOIN T USING (category);

For Explanation got to 1907. Count Salary Categories

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@IamShiwangi
Comment options

Answer selected by IamShiwangi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/iamAntimPal/LeetCode_SQL_Database/discussions/22

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy