Your question is Top Products in First Week. 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.
Blinkit wants to understand which products new users purchase soon after registration. Write a PostgreSQL query to identify the top five products purchased during each user's first seven days on the platform.
registered_at through, but not including, registered_at + INTERVAL '7 days'.status = 'completed' and non-null matching products.product_id ascending and return exactly the top five ranked products.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique Blinkit user identifier |
| registered_at | TIMESTAMP | Timestamp when the user registered |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| user_id | INT | User who placed the order |
| product_id | INT | Purchased product identifier |
| ordered_at | TIMESTAMP | Timestamp when the order was placed |
| status | VARCHAR(20) | Order fulfillment status |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product name shown in Blinkit |