|
-
[QUOTE][i]Originally posted by chrisrlong [/i]
[B]
SELECT
--C1,
--C2
FROM
--(
--SELECT
----C1,
----C2,
----ROWNUM
------AS QUERY_ROWNUM
--FROM
----TABLE
--WHERE
----ROWNUM < Y
--/* You can add an ORDER BY here if you want */
--) T1
WHERE
--T1.QUERY_ROWNUM > X
[/B][/QUOTE]
In Development forum, where seralex asked this same question, I sugested the following:
SELECT c1, c2 FROM
----(SELECT c1, c2 FROM table1 ORDER BY c1)
--WHERE ROWNUM < Y
MINUS
SELECT c1, c2 FROM
----(SELECT c1, c2 FROM table1 WHERE c2 < X ORDER BY c1)
--WHERE ROWNUM < X
On which Chris suggested to me to take a look at his sollution as a more efficient one. I aggree that his sollution is much more efficient as it is written now, but if one follows his comment and include ORDER BY in the inline view, his sollution is *wrong*.
I think we would all agree that sliding window mechanism is only usefull if it is applied to a previously sorted total resultset. That is why I included ORDER BY in my inline views. So if we follow this business requiremnet, we have to do what Chris sugested in his comment - we must include ORDER BY in his inline view T1. But if we do this then the records from his T1 will not be selected in a sorted order, because ROWNUM is applied before the sorting is done. In other words, Y number of records will be selected in a random fashion, then this Y records will be sorted and applied QUERY_ROWNUM values. When we will want to move our sliding window in a next step we will be in troubles because we will find out that the new window is not starting at the position where the previus ended!
HTH,
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|