Posted by Aaron Bertrand [SQL Server MVP] on 11/12/06 22:08
SELECT s.*
FROM sometable s
INNER JOIN
(
SELECT rec_id,
rs = MAX(rec_sequence)
FROM alppremh
GROUP BY rec_id
) a
ON s.rec_id = a.rec_id
AND s.rec_sequence = a.rs;
"klabu" <noone_at_gmail_dot_com> wrote in message
news:12lf5tld76k2o21@corp.supernews.com...
> How to write an equivalent SQL like this (which works on Oracle):
>
> SELECT * FROM sometable
> WHERE rec_id, rec_sequence
> IN (SELECT rec_id, MAX( rec_sequence) FROM alppremh GROUP BY rec_id)
>
> thanks
>
Navigation:
[Reply to this message]
|