在oracle 的scott用户表下查询全表 使用rownum 代码如下: select * from emp where rownum >2为什么一条都数据都没有。

rownum只能用于<,如果要用>要么用rownumber()OVER,要么就实例化

rownumber()over:
select  * from (select t.*,row_number()over(order by empno desc) rn from emp t) a where a.rn=2;
实例化:
select * from (select t.*,rownum rk from (select * from emp order by empno desc) t)c where c.rk =2;
MsSql就倒数再倒数:
select top 1 * from (select top 2 * from emp t order by t.empno desc) t1 order by empno
 

相关文章:

  • 2022-12-23
  • 2021-04-12
  • 2022-03-10
  • 2022-12-23
  • 2021-12-19
  • 2021-07-24
  • 2021-07-12
  • 2021-06-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案