Problem Description –
Write an SQL query to report the number of cubic feet of volume the inventory occupies in each warehouse.
Return the result table in any order.
The query result format is in the following example.


Problem Link – Warehouse Manager
Difficulty Level – Easy
Solution –
WITH t1 as (
SELECT
product_id,
width * length * height as vol
FROM Products
), t2 as (
SELECT
w.name,
w.units * vol as volume
FROM Warehouse as w JOIN t1
ON w.product_id = t1.product_id
)
SELECT
name as warehouse_name,
SUM(volume) as volume
FROM t2
GROUP BY 1