The query should not use both rownum > and rownum <.
You may get wrong result set.