Your question is First Product Purchased Per Customer. Start with the requirements and the three tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write a PostgreSQL query to find the first product each customer purchased on the Apidel Technologies platform. Return the customer, the first order, its timestamp, and the product name. If two orders share the same earliest timestamp for a customer, use the smaller order_id as the tie-breaker.
| Column | Type | Description |
|---|---|---|
| customer_id | INT | Primary key |
| customer_name | VARCHAR(100) | Customer name |
| Column | Type | Description |
|---|---|---|
| order_id | INT | Primary key |
| customer_id | INT | Customer reference |
| product_id | INT | Product reference |
| purchased_at | TIMESTAMP | Purchase timestamp |
| Column | Type | Description |
|---|---|---|
| product_id | INT | Primary key |
| product_name | VARCHAR(100) | Product name |