Top 40% by salary in a department: departments 10–19, active
Instructions
Consider only active employees (fired_at IS NULL) from the departments with department_id from 10 to 19 inclusive. For each employee compute cume_dist() within their department by salary descending: the share of the department's employees whose salary is at least as high as theirs (equal salaries get the same value). Output the employees whose cume_dist is at most 0.4 (the top 40% of the department; everyone with an equal salary at the boundary is included or excluded together). Columns: department (the department name), name (the employee's name), salary. Row order does not matter.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Table relationships
- N:1Many-to-one
employees.→department_id departments.id - N:1Many-to-one
employees.→manager_id employees.id - N:1Many-to-one
departments.→parent_id departments.id - N:1Many-to-one
salary_history.→employee_id employees.id
Table data
Select a table in the diagram or list to view its rows.