54. Books by Prolific Authors (Uncorrelated Subquery Filter)
MediumSubqueriesuncorrelated subqueryINGROUP BYHAVING
An uncorrelated subquery computes a fixed set of values once, independent of the outer query, and that set then feeds a filter. Here we first find the prolific authors, then list all their books.
Task: an author is prolific if they have written 2 or more books. Return every book written by a prolific author.
Return columns title, author. Order by author ascending, then title ascending.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.