문제를 풀다가 자꾸 오답이라길래 왜 그런지 문제를 다시 읽어 보니 발견!
the total number of employees who have maximum total earnings를 구하려면 limit를 걸어야 하는데 걸지 않은 것 때문에 오답이었던 것이다.
연봉 높은 순으로 내림차순하면 되지 -> 가장 높은 연봉을 받는 사람들은 자연스럽게 맨 위에 뜰 테니까 (구했다!)라고 생각한 나의 잘못;_;
초중고 내내 문제를 마음대로 읽고 풀어 놓친 점수와 등급이 다시금 떠올랐다.
이렇게 쉬운 문제도 제대로 읽지 않으면 다 알고서도 틀린다.
문제를 제대로 읽자!
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.
Input Format
The Employee table containing employee data for a company is described as follows:
select months * salary as earnings, count(*)
from employee
group by earnings
order by earnings desc
limit 1