Your question is Users Who Purchased But Never Returned. 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.
DataAnnotation's purchase analytics team wants to identify users who completed at least one purchase but have never returned any purchase. Write a PostgreSQL query that joins the user, purchase, and return data.
returns table.user_id in ascending order.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| full_name | VARCHAR(100) | User's full name |
| VARCHAR(255) | User email address | |
| signup_date | DATE | Account registration date |
| status | VARCHAR(20) | Current account status |
| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique purchase identifier |
| user_id | INT | User who made the purchase |
| purchase_date | DATE | Date of purchase |
| amount | NUMERIC(10,2) | Purchase amount |
| Column | Type | Description |
|---|---|---|
| return_idPK | INT | Unique return identifier |
| purchase_id | INT | Purchase associated with the return |
| return_date | DATE | Date the purchase was returned |
| reason | VARCHAR(100) | Reason for the return |