我正在使用以下查询进行分页
SELECT * FROM (
SELECT a.*, rownum row_num FROM (
select distinct field1, field2, ...
COUNT(*) OVER () RESULT_COUNT
from table1
where condition1
order by someField desc
)a
WHERE rownum < :maxRow
)WHERE row_num > = :minRow;
我得到result_count = 294(这是总记录匹配条件),而在distinct之后返回的总记录是61.如何在result_count中得到61。换句话说,在使用distinct之后我需要总记录数。
答案 0 :(得分:1)
这是你的意思
SELECT * FROM (
SELECT a.*, rownum row_num FROM (
select field1, field2, ...
COUNT(DISTINCT field1) OVER () RESULT_COUNT
from table1
where condition1
order by someField desc
)a
WHERE rownum < :maxRow
)WHERE row_num > = :minRow;