In the process of project development, a large number of use of paging query, when you want to let the data sorted by date, there are many duplicate data appear. The cause of this problem is that in the data, the value of the date is not unique. We know
Oracle paged queries are not doing any sort operations, and Oracle is sequential to read the eligible data from the data block back to the client. Oracle's sort algorithm does not have stability, that is, for key values equal to the
Data, which, when sorted, does not guarantee that the data of these key values is equal to the order in which they were sorted.
The solution to this problem is to add a uniqueness column, such as a primary key, to solve the problem.
SELECT * FROM
(
Select A.*, RowNum rn from
(SELECT * from user ' u order by u.createdate desc, u.id desc) A
where RowNum <=20
) b
where B.rn >=0