728x90
반응형
https://www.hackerrank.com/challenges/earnings-of-employees/problem?isFullScreen=true
문제
We define an employee's total earnings to be their monthly salary x 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 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:
where employee_id is an employee's ID number, name is their name, months is the total number of months they've been working for the company, and salary is the their monthly salary.
Code
SELECT SALARY * MONTHS AS EARNING, COUNT(*)
FROM EMPLOYEE
GROUP BY EARNING
ORDER BY EARNING DESC LIMIT 1
728x90
반응형
'SQL > MySQL' 카테고리의 다른 글
[MySQL/HackerRank] Weather Observation Station 13 (0) | 2023.08.25 |
---|---|
[MySQL/HackerRank] Weather Observation Station 2 (0) | 2023.08.25 |
[MySQL/HackerRank] African Cities (0) | 2023.08.21 |
[MySQL/HackerRank] Population Census (0) | 2023.08.21 |
[MySQL/HackerRank] Average Population of Each Continent (0) | 2023.08.21 |