分组查询取最大时间记要的多种方式
分组查询取最大时间记录的多种方式sql语句:select t2.* from(select t1.*,row_number() over(partition by
分组查询取最大时间记录的多种方式
sql语句:
select t2.* from (select t1.*,row_number() over (partition by t1.sheet_id order by t1.check_time desc nulls last) rn from dispatch_result t1) t2 where rn=1
DR_ID SHEET_ID CHECK_NEXT CHECK_TIME CHECK_SN CHECK_COMMENT CHECK_STATUS
---------- ---------- -------------------- ----------- -------- -------------------------------------------- ------------
2 1 10002 2012/9/15 11:15:24 10001 2
4 2 10002 2012/9/18 11:16:23 10001 2
结果都是一样的,至于效率求大神指教。