如何选择另一个选择查询的结果的第10、20、30 ...行 [英] How can I select 10th, 20th, 30th ... row of the result of another select query

查看:61
本文介绍了如何选择另一个选择查询的结果的第10、20、30 ...行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,该表的列为tofromID.我只需要选择每10个IDAB的行.

解决方案

select * from 
(select * from table where from = 'A' and to ='B' order by ID)
where mod(rownum/10,1) = 0

它首先只将那些从"A"到"B"的数字,然后给它们行号,并仅选择第20个ETC位置的第10个数字.

I have a table with a column to, from and ID. I need to select only rows with every 10th ID which is from A to B.

解决方案

select * from 
(select * from table where from = 'A' and to ='B' order by ID)
where mod(rownum/10,1) = 0

It first takes only those from 'A' to 'B', then giving them rownums, and selecting only those in the 10th 20th ETC places..

这篇关于如何选择另一个选择查询的结果的第10、20、30 ...行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆