-
Top Earners MySQLHackerRank/SQL 2023. 2. 13. 18:00
문제
https://www.hackerrank.com/challenges/earnings-of-employees/problem
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
풀이
- 서브쿼리를 이용해 MAX 값과 개수를 센다.
SELECT SALARY * MONTHS AS A, COUNT(*) FROM EMPLOYEE GROUP BY A HAVING A = (SELECT MAX(SALARY * MONTHS) FROM EMPLOYEE)
참조
https://jogrammer.tistory.com/181
[해커랭크(Hacker Rank)] Top Earners (MySQL)
문제 We define an employee's total earnings to be their monthly salary * months 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 emplo
jogrammer.tistory.com
'HackerRank > SQL' 카테고리의 다른 글
Population Census MySQL (0) 2023.02.16 Weather Observation Station 20 MySQL (0) 2023.02.15 Binary Tree Nodes MySQL (0) 2023.02.11 Occupations MySQL (0) 2023.02.10 The PADS MySQL (0) 2023.02.10