Dedup via ROW_NUMBER + PARTITION.
For each customer, return their most recent order. Columns: `customer_id`, `product_name`, `order_date` (as YYYY-MM-DD text), `revenue`. Order by customer_id. Table: `ci_orders`.
| Column | Type | Key |
|---|---|---|
| order_id | INT | PK |
| customer_id | INT | |
| product_name | TEXT | |
| category | TEXT | |
| order_date | DATE | |
| revenue | NUMERIC |
Each hint you reveal reduces the XP you can earn. Try the query first.
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date DESC).
Filter where the row number = 1 in an outer query or CTE.
Cast the date with TO_CHAR(order_date, 'YYYY-MM-DD') so the column is a plain text date.