Hi
I have below query . I want to display QtyIn-Qty Out and difference should be > 0
SELECT T1."WhsCode",T1."ItemCode",T1."BatchNum",
(Select Sum("Quantity") from IBT1 where "WhsCode" = T1."WhsCode" and "ItemCode" = T1."ItemCode" and "BatchNum" = T1."BatchNum" and "Direction" = 0) As "Qty In",
(Select Sum("Quantity") from IBT1 where "WhsCode" = T1."WhsCode" and "ItemCode" = T1."ItemCode" and "BatchNum" = T1."BatchNum" and "Direction" = 1) As "Qty Out"
FROM IBT1 T1
Left Join OITM T2 on T2."ItemCode" = T1."ItemCode"
group by T1."WhsCode",T1."ItemCode",T1."BatchNum"
Thanks
Muhammad Imran AnsariPosted Feb 11, 2025, 6:40 AM
Hello Ramco,
To display the difference between
Qty InandQty Outwhere the difference is greater than 0, you can modify your query to include aHAVINGclause. TheHAVINGclause is used to filter results after theGROUP BYhas been applied. Here's how you can adjust your query: