Top Earners

  • + 17 comments

    For more literal code:

    select salary*months as earnings, count(*) from employee
    group by earnings
    order by earnings desc limit 1;
    

    For more lazy:

    select salary*months as earnings, count(*) from employee
    group by 1
    order by 1 desc limit 1
    

    To use WHERE:

    select salary*months, count(*) from employee
    where salary*months = (select max(salary*months) from employee)