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.
| Author |
Topic |
|
hisouka
Starting Member
28 Posts |
Posted - 2009-08-03 : 04:23:36
|
| I guys,I have a Table hereOutlet--------Product-------Invoice-------Date------Quantity4-------------101-----------1-------------1/1/2009--504-------------101-----------10------------2/1/2009--104-------------103-----------12------------3/1/2009--904-------------103-----------15------------1/1/2009--110I 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 101and outlet 4 product 103. SO it must output:Outlet--------Product-------Invoice-------Date------Quantity4-------------101-----------10------------2/1/2009--104-------------103-----------12------------3/1/2009--90Because 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,quantityfrom (select row_number()over(partiton by outlet,product order by date desc)As rid,* from tablename) where rid =1 |
 |
|
|
|
|
|