36. Count Salary Categories | SQL Interview Questions and Answers

  Рет қаралды 1,701

Start Practicing

Start Practicing

Күн бұрын

Пікірлер: 4
@shubhamkumar4800
@shubhamkumar4800 2 күн бұрын
# Write your MySQL query statement below select 'Low Salary 'as category , count(account_id) as accounts_count from accounts where income < 20000 union select 'Average Salary'as category , count(account_id) as accounts_count from accounts where income between 20000 and 50000 union select 'High Salary'as category , count(account_id) as accounts_count from accounts where income > 50000 order by accounts_count desc i got the result but this one not worked , any idea why ?
@pasumarthiashik1099
@pasumarthiashik1099 7 ай бұрын
SELECT CASE WHEN income < 20000 THEN 'Low Salary' WHEN income >= 20000 AND income
@AbhishekYadav-g4h
@AbhishekYadav-g4h 6 ай бұрын
this won't work for returning the average salary row when account's count is 0. else use below code using left join : WITH Categories AS ( SELECT 'High Salary' AS category UNION ALL SELECT 'Low Salary' UNION ALL SELECT 'Average Salary' ) select c.category, coalesce(a.accounts_count, 0) as accounts_count from categories c left join (select case when income > 50000 then 'High Salary' when income < 20000 then 'Low Salary' else 'Average Salary' end as category, coalesce(count(account_id), 0) as accounts_count from Accounts group by category ) as a on c.category = a.category;
@pukhrajrathkanthiwar2176
@pukhrajrathkanthiwar2176 3 ай бұрын
madam please remove like it's irritating
40. Restaurant Growth | SQL Interview Questions and Answers
13:12
Start Practicing
Рет қаралды 2,2 М.
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
39. Movie Rating | SQL Interview Questions and Answers
12:04
Start Practicing
Рет қаралды 2 М.
38. Exchange Seat | SQL Interview Questions and Answers
7:37
Start Practicing
Рет қаралды 1,8 М.
50. Find Users With Valid E-Mails | SQL Interview Questions and Answers
6:55