I have an Oracle query
select max(m.id),
m.someId keep (DENSE_RANK FIRST ORDER BY m.UpdateDate desc)
from MyTable m
groupBy m.someId
which for data like this:
id UpdateDate someId
1 20-01-2012 10
2 20-01-2012 10
3 01-01-2012 10
4 10-02-2012 20
5 01-02-2012 20
6 01-04-2012 30
will return me exactly this:
2 10
4 20
6 30
So, for every someId it searches for latest updateDate and does return the appropriate id. (And if there are a several ids for the latest dates it takes latest id).
But for SQL server will this query work the same way? I mean this construction keep (dense_rank first order by ..)?
I don’t think that your particular query will run SQL Server. But you can achieve the same result doing this: