Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SKU not used within last 2 years

Author  Topic 

martilio
Starting Member

2 Posts

Posted - 2009-09-11 : 12:08:06
We will be removing from inventory items that were not used within past 2 years. I need to show these items on the report. How can I do that using SQL Query.

Thanks in advance.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-11 : 13:37:11
with something like this:

select sku, max(saleDate) as LastSaleDate
from <sales Table>
group by sku
having max(saleDate) < dateadd(year, -2, getdate())

Be One with the Optimizer
TG
Go to Top of Page

martilio
Starting Member

2 Posts

Posted - 2009-09-11 : 14:11:06
This is what I needed, THANK YOU TG!!
Go to Top of Page
   

- Advertisement -