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 |
Bartroels
Starting Member
1 Post |
Posted - 2014-06-25 : 03:51:19
|
I have a list with items and their invoiced price and date:for exampleITEM1 1.45 13/2/14ITEM2 5.88 4/4/14ITEM1 1.50 19/4/14ITEM3 4.44 15/3/14ITEM2 6.00 19/5/14ITEM1 1.48 13/3/14ITEM3 4.24 12/5/14I want now for EACH item the price at the most recent date -->ITEM1 1.50 19/4/14ITEM2 6.00 19/5/14ITEM3 4.24 12/5/14I tried several ways, with correlated query, HAVING, WHERE,... but I don't reach the desired result Can anyone help me, I think the solution is simple but I don't see it!thanks!!Bart |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2014-06-25 : 04:09:13
|
select * from(select row_number() over (partition by item order by invoicedate desc) as rn,* from yourtable) as dtwhere rn = 1 Too old to Rock'n'Roll too young to die. |
|
|
|
|
|