items(item_id, item_type, square_footage) and
warehouses(warehouse_id, capacity_sqft)
A premium bundle holds one of every distinct item_type that starts with
'premium_'. Its footprint is the sum of those types' square footage, and each
type has one canonical footprint however many rows it has.
For each warehouse, return how many complete bundles fit and how much space is left over. Partial bundles do not count.
Return warehouse_id, full_bundles and unused_sqft rounded to two decimals,
ordered by warehouse_id.
Summing square_footage straight off the table counts duplicate rows of the same
type, which inflates the bundle and undercounts what fits.
Tables
items
item_id item_type square_footage
------- -------------- --------------
1 premium_laptop 10.00
2 premium_laptop 10.00
3 premium_laptop 10.00
4 premium_phone 5.00
5 premium_tv 10.00
6 standard_chair 50.00
warehouses
warehouse_id capacity_sqft
------------ -------------
1 100.00
2 62.50
3 24.00
Expected result
warehouse_id full_bundles unused_sqft
------------ ------------ -----------
1 4 0.00
2 2 12.50
3 0 24.00