Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Never-ordered customers via NOT EXISTS

SQL data engineering interview problem. Difficulty: advanced. Pattern: Subqueries. About 18 minutes. Part of the Pro drill bank.

Same result as problem 13: customers with no lb_orders rows. Implement it with NOT EXISTS (not LEFT JOIN). Return customer_id, name ordered by customer_id.

Constraints

  • Do not use LEFT JOIN for this problem.

Examples

Input: customers customer_id | name C03 | Cam C04 | Dee C05 | Eli lb_orders (matching customer_ids) customer_id | order_id C03 | 6 Output: customer_id | name C04 | Dee C05 | Eli Why this passes: NOT EXISTS returns true when the correlated subquery finds zero rows.

Topics: lakebench, sql, not exists, anti-join.

More SQL interview questions · All interview problems · Learn data engineering

advanced

Never-ordered customers via NOT EXISTS

Interview-style drill: Rewrite the anti-join with NOT EXISTS.

Same result as problem 13: customers with no `lb_orders` rows. Implement it with NOT EXISTS (not LEFT JOIN). Return `customer_id`, `name` ordered by `customer_id`.