I have two databases. 1. Oracle 2. SQL Server
Both have the same table TABLE
. I have to fetch data in limits, order by some columns, in both the table and validate it (against each other).
Suppose the limit is 100 to 150
For SQL I am using
select *
from (
select row_number() over (order by specific_column) as row, *
from Table
) as t
where row between 100 and 150
For Oracle I am using
select *
from (
select columnname, rownum r
from Table
) a where a.r>=100 and a.r<=150 order by specific_column
But the results I am getting is entirely different in each output.
May be the orderby is working first in sqlserver and then its fetching it by rownum, and vice versa in oracle.
PS: Please note that, the version of oracle what I am using is 7.3.x and order by in subquery is not supported.