I need to determine which inventory items we currently have in stock that have not moved in the past 90 days so we can try and use them up. I am trying to look at all line items on an invoice within the past 90 days, but only include all of the items that do NOT show up on these invoices. However, it is not giving me the results I need. Please help. Below is what I have so far (OITM is the item table and INV1 is the invoice rows):
Set ANSI_NULLS OFF
declare @strt as datetime
declare @d90 as datetime
set @strt = dateadd(day, 0, Getdate())
set @d90 = dateadd(day, -90, @strt)
SELECT T0.ItemCode, T0.OnHand, T0.LastPurPrc, T0.onhand * T0.LastPurPrc AS 'Total'
FROM OITM T0 LEFT JOIN INV1 T1
ON T0.ItemCode = T1.ItemCode
WHERE (t1.docentry = Null OR t1.docdate not between @d90 and @strt)
AND T0.OnHand != 0
/* This query returns the item numbers, the in stock qty, last purchase price and total cost of inventory in stock of all items not sold within the past 90 days. It does includes the following:
- items not on an invoice at all
- items not on an invoice within the past 90 days
- items with inventory in stock*/
Set ANSI_NULLS OFF
declare @strt as datetime
declare @d90 as datetime
set @strt = dateadd(day, 0, Getdate())
set @d90 = dateadd(day, -90, @strt)
SELECT T0.ItemCode, T0.OnHand, T0.LastPurPrc, T0.onhand * T0.LastPurPrc AS 'Total'
FROM OITM T0 LEFT JOIN INV1 T1
ON T0.ItemCode = T1.ItemCode
WHERE (t1.docentry = Null OR t1.docdate not between @d90 and @strt)
AND T0.OnHand != 0
/* This query returns the item numbers, the in stock qty, last purchase price and total cost of inventory in stock of all items not sold within the past 90 days. It does includes the following:
- items not on an invoice at all
- items not on an invoice within the past 90 days
- items with inventory in stock*/