SQL QuestSQL Interview Questions › Joins

Management Hierarchy Overview

MediumFreeQuerying BasicsJoinsSubqueries & CTEsNULL HandlingConditional Logic

For each employee, show: name, position, salary, manager_name (or 'No Manager' for top-level), and role_type ('Manager' if they have any direct reports, 'Individual Contributor' otherwise). Sort by salary descending.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

employees

emp_idnamedepartmentpositionsalaryhire_datemanager_idperformance_rating
1Alice JohnsonEngineeringSenior Developer950002019-03-1554.5
2Bob SmithEngineeringDeveloper750002020-06-0113.8
3Carol WilliamsMarketingMarketing Manager850002018-09-20NULL4.2

Expected output: All employees with manager name and whether they manage others

Hint

LEFT JOIN employees m ON e.manager_id = m.emp_id gives manager name. EXISTS (SELECT 1 FROM employees sub WHERE sub.manager_id = e.emp_id) checks for direct reports

Concepts

SELECT LEFT JOIN EXISTS Subquery COALESCE Self-Join CASE Self-Join + EXISTS

Practise the topic: SQL practice questions · JOIN practice · CTE practice · NULL handling practice · CASE WHEN practice

In these company practice sets

Google · Snowflake

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Customers Who Never OrderedMedium · FreeAbove-Average Departments (Derived Table)Medium · FreeLEFT JOIN NULL Semantics: Inactive CustomersMedium · FreeCount Direct ReportsMedium · FreeCustomer Recency AnalysisMedium · FreeMembership Tier Revenue AnalysisMedium · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test