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

Re: Find closest date in SQL

$
0
0

Hi Alaa

 

I tried this as you suggested:

 

SELECT T0.[ItemCode], T0.[ItemName], T0.[OnHand]'Physical_Stock', T0.[IsCommited]'On_Sales_Order', T0.[OnOrder]'On_Purchase_Order',

                                CASE WHEN t0.onorder=0 THEN null ELSE min(T2.[ShipDate])

end as 'Expected_Delivery',SUM(T1.[Quantity])'Invoiced_Qty_12_months'

FROM OITM T0 LEFT JOIN INV1 T1 ON T0.ItemCode = T1.ItemCode LEFT JOIN POR1 T2 ON T0.ItemCode = T2.ItemCode

WHERE (T0.[ItemCode] like 'COV%' and t2.shipdate > getdate())

GROUP BY T0.[ItemCode], T0.[ItemName], T0.[OnHand], T0.[IsCommited], T0.[OnOrder]

 

 

Unfortunately it only shows me results where there is a ship date so I lose a lot of the results where there no ship date.   I need to see ALL the item which are LIKE 'COV%' whether they have a expected delivery or not

 

Regards

Jason


Viewing all articles
Browse latest Browse all 9269

Trending Articles



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