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
|
3089 Discussions
|
Please Login in order to post a comment
select salary*months as earnings, count(salary*months) from employee group by earnings order by earnings desc limit 1;
SELECT (salary*months) , COUNT(salary*months) FROM Employee GROUP BY (salary*months) ORDER BY (salary*months) DESC LIMIT 1;
MS SQL Server
SELECT TOP 1 salary * months AS earnings , COUNT(*) FROM Employee GROUP BY salary * months ORDER BY earnings DESC;
Can someone tell me what is wrong with: SELECT concat(MAX(EARNING),' ',Count(*)) FROM (SELECT (SALARY*MONTHS) AS EARNING FROM employees) AS FULL;
MySQL (I think I overthought it lol): WITH a AS ( SELECT employee_id, salary * months AS tot_earn FROM EMPLOYEE ), b AS ( SELECT employee_id, MAX(tot_earn) AS max_earn FROM a GROUP BY employee_id ) SELECT b.max_earn, COUNT(*) FROM b GROUP BY b.max_earn ORDER BY b.max_earn DESC LIMIT 1;