Posts Top Earners
Post
Cancel

Top Earners

Top Earners

  • URL : https://www.hackerrank.com/challenges/earnings-of-employees/problem
  • 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 employees as well as the total number of employees who have maximum total earnings. Then print these values as 2 space-separated integers.
  • MySQL Solution
1
2
3
4
select months * salary as earnings, count(*) 
from employee
group by earnings
order by earnings desc limit 1
This post is licensed under CC BY 4.0 by the author.