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