Write SQL and Python, run instantly in your browser, and track your progress.
You are a Category Manager at Target. The team needs to spotlight the newest additions across categories. For each category, your task is to show the two most recently added active items with their names and prices, including a rank of 1 (newest) and 2 (next). Sort categories alphabetically; within each category, show most recent first and break ties by the smallest item identifier. Only include items that are currently active.
| Column Name | Type |
|---|---|
| product_id | INTEGER |
| sku | TEXT |
| product_name | TEXT |
You are a Category Manager at Target. The team needs to spotlight the newest additions across categories. For each category, your task is to show the two most recently added active items with their names and prices, including a rank of 1 (newest) and 2 (next). Sort categories alphabetically; within each category, show most recent first and break ties by the smallest item identifier. Only include items that are currently active.
| Column Name | Type |
|---|---|
| product_id | INTEGER |
| sku | TEXT |
| product_name | TEXT |
| category |
| category |
| TEXT |
| TEXT |
| price | REAL |
| price | REAL |
| currency | TEXT |
| currency | TEXT |
| is_active | INTEGER |
| is_active | INTEGER |
| weight_kg | REAL |
| weight_kg | REAL |
| created_at | TEXT |
| created_at | TEXT |
| product_id | sku | product_name | category | price | currency | is_active | weight_kg | created_at |
|---|---|---|---|---|---|---|---|---|
| 1 | SKU-10001 | Casper Original Mattress Queen | Home | 1095.0 | USD |
| product_id | sku | product_name | category | price | currency | is_active | weight_kg | created_at |
|---|---|---|---|---|---|---|---|---|
| 1 | SKU-10001 | Casper Original Mattress Queen | Home | 1095.0 | USD |
| category | product_id | product_name | price | category_rank |
|---|---|---|---|---|
| Apparel | 26 | Hanes ComfortSoft T-Shirt 6-Pack | 21.0 | 1 |
| Apparel | 46 | Nike Air Force 1 '07 | 110.0 | 2 |
| Beauty | 47 | Paula's Choice 2% BHA Exfoliant | 34.0 | 1 |
| category | product_id | product_name | price | category_rank |
|---|---|---|---|---|
| Apparel | 26 | Hanes ComfortSoft T-Shirt 6-Pack | 21.0 | 1 |
| Apparel | 46 | Nike Air Force 1 '07 | 110.0 | 2 |
| Beauty | 47 | Paula's Choice 2% BHA Exfoliant | 34.0 | 1 |
Showing first 5 of 16 rows. Two newest active items per category.
Showing first 5 of 16 rows. Two newest active items per category.
| 1 |
| 1 |
| 31.75 |
| 31.75 |
| 2025-02-14 10:57:38 |
| 2025-02-14 10:57:38 |
| 2 | SKU-10002 | Dyson Supersonic Hair Dryer | Beauty | 429.99 | USD | 1 | 0.66 | 2025-02-27 07:20:29 |
| 2 | SKU-10002 | Dyson Supersonic Hair Dryer | Beauty | 429.99 | USD | 1 | 0.66 | 2025-02-27 07:20:29 |
| 3 | SKU-10003 | CalDigit TS4 Thunderbolt Dock | Office | 399.99 | USD | 1 | 0.5 | 2024-12-11 00:49:57 |
| 3 | SKU-10003 | CalDigit TS4 Thunderbolt Dock | Office | 399.99 | USD | 1 | 0.5 | 2024-12-11 00:49:57 |
| 4 | SKU-10004 | Under Armour Tech 2.0 T-Shirt | Sports | 25.0 | USD | 1 | 0.15 | 2024-11-22 04:49:00 |
| 4 | SKU-10004 | Under Armour Tech 2.0 T-Shirt | Sports | 25.0 | USD | 1 | 0.15 | 2024-11-22 04:49:00 |
| 5 | SKU-10005 | Staples TRU RED Copy Paper 10-Ream | Office | 54.99 | USD | 1 | 22.68 | 2025-01-10 01:43:59 |
| 5 | SKU-10005 | Staples TRU RED Copy Paper 10-Ream | Office | 54.99 | USD | 1 | 22.68 | 2025-01-10 01:43:59 |
| Beauty | 2 | Dyson Supersonic Hair Dryer | 429.99 | 2 |
| Beauty | 2 | Dyson Supersonic Hair Dryer | 429.99 | 2 |
| Books | 31 | Becoming by Michelle Obama | 19.99 | 1 |
| Books | 31 | Becoming by Michelle Obama | 19.99 | 1 |