Algorithm & SQL/HackerRank

[HackerRank / MySQL] Top Earners

김룹 2024. 3. 10. 11:58

 

 

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

 

 

 

 

SELECT salary * months as earnings
    ,COUNT(*)
FROM employee
GROUP BY earnings
ORDER BY earnings DESC
LIMIT 1

 

 

느낀 점 및 정리 ✍️

1. maximum total earnings => Max(salary * months)

2. total number of employees who have maximum total earnings => GROUP BY earnings , COUNT(*)