Probably the easiest way will be just to count the number of unique SKUs in the SKU_Data
, then select all the WarehouseID
from the Inventory
that have less than that number of unique SKUs.
Critically, this assumes a warehouse doesn't have a SKU that is missing from the SKU table.
Also assuming Inventory(WarehouseID,SKU)
& SKU_Data(SKU)
are unique
select WarehouseID from Inventory group by SKU
having count(*) < (select count(*) from SKU_Data)
I've not tested this, but I think it's about right :)
If this doesn't work, you can always select the count(*)
into a local variable, something like
select @skunum := count(*) from SKU_Data
select WarehouseID from Inventory group by SKU having count(*) > @skunum
If you want to also check the warehouse has the item in stock, just add where QuantityOnHand > 0
, after from Inventory
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…