Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query - ONLY inventory that hasn't moved in past 90 days

Status
Not open for further replies.

Melanie1

IS-IT--Management
Apr 10, 2008
4
0
0
US
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*/
 
What about this ?
Code:
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 AND T1.docdate BETWEEN @d90 And @strt
WHERE T1.docentry IS NULL AND T0.OnHand != 0


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top