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
|
3452 Discussions
|
Please Login in order to post a comment
my sql
SELECT SALARY * MONTHS AS TOTAL, count(*) FROM EMPLOYEE group by total desc limit 1
select max(salary*months), count(salary) from employee group by salary*months order by salary*months desc limit 1
SELECT MAX(months * salary) AS max_earnings, COUNT(*) FROM employee WHERE salary * months = (SELECT MAX(months * salary) FROM employee);
MS SQL Server:
with abc as (select name,(months*salary) as earnings from employee),
def as (select earnings,count(name) as names from abc group by earnings)
select top 1 * from def order by earnings desc
For MySQL
SELECT MAX(MONTHS*SALARY), COUNT(*) FROM EMPLOYEE GROUP BY(MONTHS*SALARY) ORDER BY MONTHS*SALARY DESC LIMIT 1;