E-commerce: Customers Who Placed an Order (IN Subquery)
SQL coding challenge · Difficulty: easy · +50 XP
Problem
Your loyalty program wants to email every customer who has placed at least one order. Find them using an IN subquery (not a JOIN).
Tables
Table: Customer
| customer_id | name | email | | --- | --- | --- | | 1 | Prince | prince@gmail.com | | 2 | Mohit | mohit@gmail.com | | 3 | Rahul | rahul@gmail.com | | 4 | Krishna | krishna@gmail.com |
Table: Orders
| order_id | customer_id | order_date | total_amount | | --- | --- | --- | --- | | 101 | 1 | 2024-05-01 | 1500 | | 102 | 2 | 2024-05-02 | 2300 | | 103 | 3 | 2024-05-03 | 1800 | | 104 | 4 | 2024-05-04 | 2700 | | 105 | 1 | 2024-05-05 | 1100 |
Expected Output
| customer_id | name | | --- | --- | | 1 | Prince | | 2 | Mohit | | 3 | Rahul | | 4 | Krishna |
- Return:
customer_id,name,email - Must use an IN subquery (not a JOIN)
- Sort by
customer_idascending