oracle eg: 方法1:SELECT NO, SJ ROW_NUMBER () OVER(PARTITION BY NO ORDER BY SJ DESC) ET FROM TAB 方法2: select a.* from tab a where exists(select 1 from (select no, max(sj) sj from tab group by no) b where b.no = a.no and b.sj = a.sj);
在数据量比较大的时候,方法2的速度要比方法1的快很多.