Practice · History · Medium
Return the names of pharaohs who appear as the builder of at least one monument, alphabetically.
Runs in your browser. No signup needed.
pharaohs WHERE name IN (SELECT builder FROM monuments). A subquery can feed an IN list.
SELECT name
FROM pharaohs
WHERE name IN (SELECT builder FROM monuments)
ORDER BY name;
The reference solution is checked automatically when you run your query on the practice page — results are compared row by row, and order matters for this one.
IN (SELECT …) is a set-membership test — “is this name anywhere in that list?”. (SQLite docs)