Dear Experts,
SELECT T0.ItemCode, T0.Dscription,T1.OnHand, SUM(T0.BaseQty*T1.NumInSale) AS 'Qty Sales',DAY(GetDate()) as 'Days',
Case WHEN Month(GetDate()) in (1,3,5,7,8,10,12) THEN 31 WHEN Month(GetDate()) in (2,4,6,9,11) THEN 30 ELSE 28 END AS 'Total days'
,(t1.onhand/(SUM(T0.BaseQtyT1.NumInSale)/DAY(GetDate()) Case WHEN Month(GetDate()) in (1,3,5,7,8,10,12) THEN 31 WHEN Month(GetDate()) in (2,4,6,9,11) THEN 30 ELSE 28 END))AS 'TURN OVER IN MONTH'
FROM DBO.INV1 T0 INNER JOIN DBO.OITM T1 ON T0.ItemCode = T1.ItemCode
WHERE Month(T0.DocDate) = Month(GetDate()) AND Year(T0.DocDate) = Year(GetDate())
AND (T0.BaseQty*T1.NumInSale)>0
GROUP BY T0.ItemCode,T0.Dscription,T1.OnHand
ORDER BY T0.ItemCode
how to write query that displays all of the stock sold and Onhand not sold. because this query to display the items sold this month.
Thanks for your help