首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

分组查询取最大时间记要的多种方式

2012-09-05 
分组查询取最大时间记录的多种方式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


结果都是一样的,至于效率求大神指教。





1楼jindows4天前 16:49
学习了
Re: hanzhou45194天前 18:04
回复jindows一起学习

热点排行