ITeye博客

oracel分组排序最大记录

lan13217 · 2014-08-28 17:21 · Oracle · sql · 非技术 · Markdown

sql分组查询最大记录 1.


select distinct first_value(emp_id) over(partition by emp_code order by tm.last_modify_tm desc) 
from employee tm 


2.


select *
  from (select max(t.created_tm) as maxid,emp_code
          from EMPLOYEE t
         where t.valid_flg = 1
         group by t.emp_code) mte
  left join EMPLOYEE te
    on (mte.maxid=te.created_tm and mte.emp_code=te.emp_code)

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。