TASK #201 · HardThe wrong employees ended up among department leaders
Your brief
The report must show employees whose closed deals total is above the average
for their own department. The department average is taken only over employees who have closed deals.
The query runs and the numbers look plausible, but the selection is skewed: it picks up employees from departments with large deals, while the leaders of departments with more modest totals fall out of the report.
Output name (employee name) and total_amount (value of the deals they closed).
The query runs and the numbers look plausible, but the selection is skewed: it picks up employees from departments with large deals, while the leaders of departments with more modest totals fall out of the report.
Output name (employee name) and total_amount (value of the deals they closed).
Ctrl / ⌘ + ↵
Result
Write a query and run it to see the results.
Schema
departmentsid, nameemployeesid, name, department_id, manager_id, salary, hired_atcustomersid, name, registered_atordersid, customer_id, employee_id, amount, created_atloginsuser_id, logged_at