Try this in Oracle:
select * from person
where (ID, rank) in
(select ID, max(rank) from person group by ID)
and rownum
But it's not random. Everytime when you select, the result should be the same.
You may need to add something "Randomly" select the row.
回複:聽說這裏有很多sql高手,有個簡單問題請教
所有跟帖:
• Thank you! -fafa_dd- ♀ (0 bytes) () 03/16/2009 postreply 19:24:06
• 我本來是想用self join的,但我對這個不熟,總搞錯 -fafa_dd- ♀ (0 bytes) () 03/16/2009 postreply 19:34:01