SELECT * FROM (
SELECT INNER_TABLE.*, ROWNUM PAG_NUM FROM (
SELECT ...FIELDS..., COUNT(*) OVER() PAG_TOT
FROM ...
WHERE ...
GROUP BY ...
HAVING ...
ORDER BY ...
) AS INNER_TABLE WHERE ROWNUM < :1
) WHERE PAG_NUM >= :2
As result I have for each row the fields selected and two more fields: PAG_TOT contains the number of rows selected by the inner query, and PAG_NUM that represent the rownum in the inner query.
It resolved a great performance hole, six month ago.
Credits goes to Ask Tom Oracle
Nessun commento:
Posta un commento
Hello, new comment!