说明:

floor函数:向下取整,比如floor(2.5) = 2;floor(3.0) = 3;

查询:

select floor(e2.r/ 2),floor((e2.r-1)/2),e2.* from
(select rownum r, e1.* from
  (
  select * from nhlh_sto_yggys_mid where f_pkey in (select f_pkey from nhlh_sto_yggys_mid group by f_pkey having count(1) >1) order by f_pkey
  ) e1
) e2 where floor(e2.r/ 2) >floor((e2.r-1)/2) ;

结果:

ORACLE查询某张表奇数行或者偶数行数据

解释:因为表中没有行数列,所以首先我们查询加入行数

select rownum r, e1.* from
  (
  select * from nhlh_sto_yggys_mid where f_pkey in (select f_pkey from nhlh_sto_yggys_mid group by f_pkey having count(1) >1) order by f_pkey
  ) e1

然后我们通过取整函数判断行数除2与行数减1除2的结果对比,从而查询出所需结果。查询奇数行也是一样的道理。

 

相关文章:

  • 2022-02-28
  • 2021-08-14
  • 2022-02-27
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
猜你喜欢
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
相关资源
相似解决方案