分组查询取最大时间记录的多种方式
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
结果都是一样的,至于效率求大神指教。
- 1楼jindows4天前 16:49
- 学习了
- Re: hanzhou45194天前 18:04
- 回复jindows一起学习