This query can give list of items that have negative quantity in either cost layers table or onhand quantity table.
.
SELECT b.organization_id
, b.concatenated_segments
, b.description
, cst_qty
, onhand_qty
FROM (SELECT 'cst'
, organization_id
, inventory_item_id
, layer_quantity cst_qty
, 0 onhand_qty
FROM apps.cst_quantity_layers
WHERE layer_quantity < 0
UNION ALL
SELECT 'onhand'
, organization_id
, inventory_item_id
, 0
, b.transaction_quantity
FROM apps.mtl_onhand_quantities b
WHERE b.transaction_quantity < 0
) A
, apps.mtl_system_items_vl b
WHERE A.organization_id = b.organization_id
AND a.inventory_item_id = b.inventory_item_id;
No comments:
Post a Comment