Business Intelligence Path · Mission 25 of 25Expert

The executive summary query

Combine multiple advanced techniques (window functions, subqueries, CASE WHEN, multi-table joins, NULL handling) in a single analytical query

Back to Business Intelligence

The Brief

Victoria ChenCEOslack-dm

Final boss time. I need one query that gives me, for each active Sales rep: their name, total 2025 revenue, their rank by 2025 revenue, what percentage of total 2025 Sales revenue they represent, their Q3 2025 target attainment (actual/target as a percentage — NULL if no target), and whether they are 'Above Quota' (attainment >= 100%) or 'Below Quota' or 'No Data'. Sort by 2025 revenue descending. This is going to the board as-is.

You'll practice

Multi-techniqueAdvanced analytics

Tables available

fact_salesdim_employeesfact_targets

Hints (3)

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

Hint 1

Start with a subquery that gets each active Sales rep's 2025 revenue from fact_sales

Hint 2

Add RANK() OVER and SUM() OVER() for the rank and percentage in an outer query

Hint 3

LEFT JOIN to fact_targets for Q3 2025 (quarter=3, year=2025) to get attainment — use CASE WHEN for the status flag, handling NULL actual_amount