SQL
All Top 50 SQL Interview Questions#8
IN vs EXISTS in SQL Subquery Filtering
MediumInterview Question #8
You have `customers` and `orders`. Write a query to find all customers who have placed at least one order with `status = 'shipped'`. Explain whether `EXISTS` or `IN` is more robust against NULL values.
Input Table: customers
3 rows preview| customer_id | name |
|---|---|
| 1 | Aarav |
| 2 | Bhavna |
| 3 | Chirag |
Expected Output Structure2 rows
| customer_id | name |
|---|---|
| 1 | Aarav |
| 3 | Chirag |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.