Business Intelligence Path · Mission 12 of 25Medium

Who reports to whom?

Use self-joins to navigate hierarchical relationships in a single table

Back to Business Intelligence

The Brief

Victoria ChenCEOslack-dm

HR asked for a clean org report: every employee with their manager's name alongside. Show the employee name, their title, their manager's name, and the manager's title. Include everyone — even me, though my 'manager' situation is a bit circular. Sort by manager last name, then employee last name.

You'll practice

Self-joinHierarchy

Tables available

dim_employees

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Self-join: JOIN dim_employees AS mgr ON e.manager_id = mgr.employee_id

Hint 2

The CEO's manager_id points to herself — a self-referencing record. A regular JOIN will still work; she'll show up as her own manager.

Hint 3

Use LEFT JOIN if you want to include employees whose manager_id might be NULL (though in this dataset, even the CEO has a manager_id)