DATA/SQL
[해커랭크] Top Earners - Group by
열쩡왔쩡
2025. 5. 20. 10:45
문제출처 : https://www.hackerrank.com/challenges/earnings-of-employees/problem
해설 : 끊어서 생각하기
salary * month = earnings
각 earning 별로 몇명이 그 만큼 벌어쓴ㄴ지 계산 ( 5000, 2 / 3000, 5 / 10000, 1) group by
earning 중에 가장 큰 값을 가져온다 order by, limit
그러면 이렇게 됨 :
1번 = select salary * months as earnings,
2번 = count(*)
from employee
group by earnings
3번 = order by earnings desc
limit 1
728x90