PrepZone Logo
PrepZone
Back to Database

Database · Medium

Find employees earning more than the average salary of their own department.

DatabaseSQL QueriesSeniorSubqueries

Answer preview

Compute each department's average alongside every employee with AVG() OVER (PARTITION BY dept_id), then filter in an outer query.…