java - Encountering problems with paging queries in Oracle database
PHP中文网
PHP中文网 2017-05-17 10:04:43
0
2
696

It’s like this. There is a field KS_ZKZ in my table. This field is not unique in the table. Each student number appears multiple times. Now I want to perform paging query based on this student number:
First remove duplicate student numbers and arrange them in ascending order:

SELECT DISTINCT(KS_ZKZ) from ZK.T_BYSQ_KS_KC ORDER BY KS_ZKZ ASC

After having this query result, I want to query the data from rownum a to b of this result:

SELECT KS_ZKZ,ROWNUM FROM
(SELECT DISTINCT(KS_ZKZ) from ZK.T_BYSQ_KS_KC ORDER BY KS_ZKZ ASC)
WHERE ROWNUM >=10 AND ROWNUM<=20

But a problem arises: The following are the query results. .

Why can’t it be found?

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
PHPzhong

rownum is just a pseudo column. You just need to check the rownum in the layer inside, for example

SELECT KS_ZKZ FROM
(SELECT DISTINCT(KS_ZKZ), ROWNUM rn from ZK.T_BYSQ_KS_KC ORDER BY KS_ZKZ ASC)
WHERE rn between 10 AND 20 
某草草

The judgment of rownum must start with 1. For example, =1 and <5 are all valid, but =2 and >7 must first find out the result set and then query through sub-statements (rownum requires an alias)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template