Skip to content

Instantly share code, notes, and snippets.

@iurev
Created March 23, 2018 13:58
Show Gist options
  • Save iurev/08fd2dc553b8dfc1e4d17466b42fd8f2 to your computer and use it in GitHub Desktop.
Save iurev/08fd2dc553b8dfc1e4d17466b42fd8f2 to your computer and use it in GitHub Desktop.
SQL
select e.*
from (
select department, max(salary) as max_salary
from employee
group by department
) d
join employee e
on e.salary = d.max_salary;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment