We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- SQL
- Aggregation
- Top Earners
- Discussions
Top Earners
Top Earners
Sort by
recency
|
3493 Discussions
|
Please Login in order to post a comment
After seeing answers from others I am shocked no one used CONCAT as in the expected output the expected results is not two columns but a single column containing two values with space. Here is my answer, Any query improvement is appreciated.
SELECT salary * months as earnings, COUNT(employee_id) FROM Employee GROUP BY earnings ORDER BY earnings DESC LIMIT 1;
select months*salary, count(months*salary) from Employee group by months*salary order by months*salary desc limit 1;
SELECT MAX(salary * months) as earnings, COUNT(employee_id)
FROM Employee WHERE salary * months = (SELECT MAX(salary * months) FROM Employee);
SELECT (salary * months) , COUNT(*)
FROM Employee GROUP BY (salary * months) ORDER BY (salary * months) DESC limit 1