▸_sqlgym

34. Customers Who Placed Orders

MediumJoinssemi-joinEXISTSIN

A semi-join returns rows from one table that have at least one match in another — but without duplicating them per match. We want each qualifying customer once, no matter how many orders they placed.

Task: return the name of every customer who has placed at least one order. A plain INNER JOIN would list Ava twice (she has two orders); a semi-join lists her once.

Two idiomatic forms are shown: EXISTS and IN.

Output column: name. Order by name 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
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.