不同后的记录数
Record count after distinct
我正在使用以下查询进行分页
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 后的总记录数。
你的意思是这样的
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;
我正在使用以下查询进行分页
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 后的总记录数。
你的意思是这样的
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;