Every warehouse crossed with every item
SQLHard15 min
Your task
Produce the full grid: every warehouse paired with every item, with the quantity held or 0. Return city, sku and quantity, ordered by city then 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 |
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