SELECT
IT.inv_filecode_short,
IT.inv_part_number,
IT.inv_part_description,
IT.inv_current_inventory,
IT.inv_reorder_qty,
COALESCE(SUM(CASE
WHEN PT.po_type = 'STK' AND PT.po_inv_filecode_short = IT.inv_filecode_short
THEN PT.po_store1_qty_order
ELSE 0
END), 0) AS sum_store1_qty_order_stock,
(IT.inv_reorder_qty - IT.inv_current_inventory - COALESCE(SUM(CASE
WHEN PT.po_type = 'STK' AND PT.po_inv_filecode_short = IT.inv_filecode_short
THEN PT.po_store1_qty_order
ELSE 0
END), 0)) AS reorder_qty
FROM
INVENTORY AS IT
LEFT JOIN
PO AS PT ON IT.inv_filecode_short = PT.po_inv_filecode_short
GROUP BY
IT.inv_filecode_short,
IT.inv_part_number,
IT.inv_part_description,
IT.inv_current_inventory,
IT.inv_reorder_qty
HAVING
reorder_qty > 0