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
|
3501 Discussions
|
Please Login in order to post a comment
MS SQL
SELECT max(salary*months), count(*) from employee where (salary*months) = (SELECT max(salary*months) from employee);
select (salary*months) as q, count(employee_id) from employee group by q DESC limit 1
WITH total_Earn AS ( SELECT employee_id, salary * months AS totalEarning FROM Employee ) SELECT concat(MAX(totalEarning),' ',COUNT(employee_id)) FROM total_Earn WHERE totalEarning = (SELECT MAX(totalEarning) FROM total_Earn);
SELECT salary * months, COUNT(employee_id) -- count of total earnings, count of total employees. FROM Employee GROUP BY salary * months -- to select the group of total earnings ORDER BY salary * months DESC LIMIT 1; -- ordering it by specifying the output to only First row after sorting.
SELECT CONCAT(MAX(months*salary), ' ', COUNT(*)) FROM EMPLOYEE WHERE (months*salary)=(SELECT MAX(months*salary) FROM EMPLOYEE);