SQLTeam.com | Weblogs | Forums

Values based on last date


I have a table with prices per article. But there can be more prices for one article. So I want to get a result with only the lines of the last price (based on the last date). I used the query below but I still get more lines per article.

select artref, MAX(date) as ldate,price from prices
group by artref, price

Can someone help me out of this please.
thanx !!

select *
    select *  , rn = row_number() over (partition by artref order by date desc)
    from   prices
) D
where rn  = 1


Thanx for the quick post !