oracle分组排序取第一条数据
oracle分组排序取第一条数据
/* 分组排序取第一条数据*/ SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY taskbreakid ORDER BY responsedate DESC) LEV, r.* -- select r.* FROM tablename r WHERE LEV = 1 /* --ORDER BY responsedate DESC taskbreakid ---> 分组列 responsedate ---> 分组中排序列 tablename ---> 表名 */ /* 取第一条数据 */ select * from ( select * from tablename t order by paisulie ) where rownum = 1