Story campaign - Chapter 13

Learn SQL Subqueries: THE DIRECTOR

A formal mole hunt is underway. Certain analysts are opening files they have no reason to see, and the access logs know who.

Mission briefing

THE DIRECTOR is chapter 13, the subqueries chapter. ACCESS_LOGS records every classified file an analyst touched; ANALYSTS holds the personnel. You nest one SELECT inside another, using IN to find analysts who reached top-secret material and NOT IN to clear the ones who never did.

The final stage raises the bar: compare each analyst's activity against the average, which means feeding an aggregate subquery into your filter. Writing a query inside a query is the moment SQL starts feeling like a real language.

The subqueries and EXISTS guide linked below is the recommended pre-read.

A query pattern from this chapter

This is the shape of query you practice here, not the answer to any mission. The real stages come with their own data, objectives, and hints.

SELECT NAME, DEPARTMENT
FROM ANALYSTS
WHERE ID IN (
  SELECT ANALYST_ID FROM ACCESS_LOGS WHERE CLASSIFICATION = 'SIGMA'
);

Related guides

Play Director now

Free in your browser, desktop only. Guest mode starts instantly with no signup; sign in with Google if you want progress saved across devices.

Play free