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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Most Recent Transaction

Author  Topic 

hisouka
Starting Member

28 Posts

Posted - 2009-08-03 : 04:23:36
I guys,

I have a Table here

Outlet--------Product-------Invoice-------Date------Quantity
4-------------101-----------1-------------1/1/2009--50
4-------------101-----------10------------2/1/2009--10
4-------------103-----------12------------3/1/2009--90
4-------------103-----------15------------1/1/2009--110

I need to query the Outlet, Product, Invoice Date, Quantity.. where the recent date of Group by Outlet and Product.. so i need to get the record of recentdate of outlet 4 product 101
and outlet 4 product 103.

SO it must output:


Outlet--------Product-------Invoice-------Date------Quantity
4-------------101-----------10------------2/1/2009--10
4-------------103-----------12------------3/1/2009--90

Because these was the recent date of group by Outlet and Product

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-08-03 : 04:51:19
select outlet,product,invoice,date,quantity
from (select row_number()over(partiton by outlet,product order by date desc)As rid,* from tablename) where rid =1
Go to Top of Page
   

- Advertisement -