SQL

[해커랭크] Top Earners

주스 JUICE 2023. 7. 18. 21:06
728x90

https://www.hackerrank.com/challenges/earnings-of-employees/problem?isFullScreen=true 

 

Top Earners | HackerRank

Find the maximum amount of money earned by any employee, as well as the number of top earners (people who have earned this amount).

www.hackerrank.com

 

문제

We define an employee's total earnings to be their monthly worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well as the total number of employees who have maximum total earnings. Then print these values as  space-separated integers.

 

세 가지 풀이방법

https://velog.io/@sehyunee_/mySQL-해커랭크-Top-Earners-3가지-풀이-방법

 

select salary * months as earnings, count(*)
from employee
group by earnings
order by earnings desc
limit 1;
728x90

'SQL' 카테고리의 다른 글

[해커랭크] Draw The Triangle 2  (0) 2023.07.20
[해커랭크] Draw The Triangle 1  (0) 2023.07.20
[해커랭크] The Blunder  (0) 2023.07.18
[해커랭크] Population Census  (0) 2023.07.18
[해커랭크] Average Population of Each Continent  (0) 2023.07.17