Question : Write a query that obtains two columns. The first column must contain annual salaries higher than 80,000 dollars. The second column, renamed to “emps_with_same_salary”, must show the number of employees contracted to that salary. Lastly, sort the output by the first column. Need output in SSMS.
Sol:
Please note, this solution below gives the output in MySql Workbench but not in SSMS.
select salary, count(emp_no) as emps_with_same_salary
from salaries
where salary > '80000'
group by emp_no;
OUTPUT:
salary emps_with_same_salary
'80001' , '7'
'80007' , '11'
'80056' , '5'