Oracle中获得经过排序的前N条记录

在最近项目中,要取出Oracle中获得经过排序的前N条记录,不能用top(N),只能用rownum关键字来实现

select n.*

  from (select m.*, rownum rw
          from (select T.*
                  from t_Km_Hotwords t
                 where t.publish_flag = 'N'
                 order by t.order_num asc) m) N
where n.rw <= N

猜你喜欢

转载自yangtaohong.iteye.com/blog/2074514
今日推荐