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
|
3180 Discussions
|
Please Login in order to post a comment
select CONCAT(max(months*salary),' ',count(*)) from employee where months*salary = (select max(salary*months) from employee);
FOR MYSQL
;With CTE (employee_id,Earning) As (SELECT employee_id, Salary * Months FROM Employee ) SELECT CAST(Earning as Varchar(100)) + ' ' + CAST(Count(*) as Varchar(10)) FROM CTE WHERE Earning in (SELECT Max(Earning) FROM CTE) GROUP BY Earning;
select max(salary*months)||' '||count(employee_id) from employee where (salary*months) = (select max(salary*months) from employee);
select top 1 salary * months, count(*) from employee group by salary * months order by salary * months desc
This worked for me. SELECT MAX(salary * months) AS max_earnings, COUNT(*) AS count_of_employees_with_max_earnings FROM Employee WHERE (salary * months) = (SELECT MAX(salary * months) FROM Employee);