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
|
3283 Discussions
|
Please Login in order to post a comment
SELECT MAX(salary*months), COUNT(*) from Employee
WHERE (salary*months) = (SELECT MAX(salary*months) from Employee);
SELECT (SALARY * MONTHS) AS EARNING, COUNT(1) FROM EMPLOYEE GROUP BY EARNING ORDER BY EARNING DESC LIMIT 1;
SELECT MAX(E.SALARY * E.MONTHS) AS MAX_TOTAL_EARNINGS, COUNT(*) AS NUM_EMPLOYEES_WITH_MAX_TOTAL_EARNINGS FROM EMPLOYEE E WHERE E.SALARY * E.MONTHS = (SELECT(MAX(E.SALARY * E.MONTHS)) FROM EMPLOYEE E);
select employee_id, months * salary as total into #total_earnings from Employee
select total, count(distinct employee_id) from #total_earnings where total = (select max(total) from #total_earnings) group by total