문제출처 : 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
'DATA > SQL' 카테고리의 다른 글
해커랭크 Revising Aggregations - Averages 외 5문제 (0) | 2025.05.16 |
---|---|
MySQL : WorkBench PK 설정 및 Table 구조 (0) | 2025.02.10 |