Zero in stock is not the same as no row
SQLHard14 min
Your task
Return every item with the total quantity across all warehouses as sku and total. An item nobody stocks at all still appears, with 0. Order by sku.
Tables
warehouse| idINTEGER | cityTEXT | countryTEXT |
|---|
| 1 | Rotterdam | NL |
| 2 | Memphis | US |
| 3 | Osaka | JP |
item| idINTEGER | skuTEXT | nameTEXT | unit_centsINTEGER |
|---|
| 1 | KB-1 | Keyboard | 4900 |
| 2 | MS-2 | Mouse | 2500 |
| 3 | MN-3 | Monitor | 19900 |
| 4 | CB-4 | Cable | 900 |
| 5 | HD-5 | Headset | 5900 |
stock| warehouse_idINTEGER | item_idINTEGER | quantityINTEGER |
|---|
| 1 | 1 | 40 |
| 1 | 2 | 0 |
| 1 | 3 | 12 |
| 2 | 1 | 5 |
| 2 | 4 | 300 |
| 3 | 3 | 7 |
More rows not shown Model answerRun