Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9159

Re: Query help. Is this possible?

$
0
0

Hi,

 

Try:

 

SELECT T.[ItemCode], max(T.[ItemName]) as 'Description', max(T.[Price]) as 'Unit Price', Max(T.[OnHand]) as 'Qty On Hand', Sum(T.[QTY1]) as 'Total QTY Last 7 Days', Sum(T.[QTY2]) as 'Total QTY Last 28 Days'

FROM

(SELECT T0.[ItemCode], T0.[ItemName], T1.[Price], T0.[OnHand], T1.[Quantity] as [QTY1], 0 as [QTY2] FROM OITM T0

left JOIN INV1 T1 ON T0.ItemCode = T1.ItemCode AND datediff(dd, T1.[DocDate],getdate()) BETWEEN 0 and 7

UNION ALL

SELECT T0.[ItemCode], T0.[ItemName], T1.[Price], T0.[OnHand], 0 as [QTY1],T1.[Quantity] as [QTY2] FROM OITM T0

left JOIN INV1 T1 ON T0.ItemCode = T1.ItemCode AND datediff(dd, T1.[DocDate],getdate()) BETWEEN 0 and 28) T

GROUP BY T.[ItemCode]

HAVING Sum(T.[QTY2]) >0

 

Thanks,

Gordon


Viewing all articles
Browse latest Browse all 9159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>