Converting SQL Server Top N to Oracle Equivalent
Date: Wed, 22 Oct 2008 18:56:43 -0700 (PDT)
Message-ID: <440560.19214.qm@web58006.mail.re3.yahoo.com>
Hi,
Gota SS2K5 query that I'm trying to convert over to Oracle 10gR2.
This is the SS2K5 query:
select top 1 ALG.time_stamp
from ALG, CHG�
where ALG.change_id = CHG.id�
and (type = 'CL' or type = 'RE')�
order by ALG.time_stamp ASC
I coded the Oracle 10gR2 equivalent as follows:
select b.time_stamp
from (
select alg.time_stamp
from ALG, CHG
where ALG.change_id = CHG.id
and (type = 'CL' or type = 'RE')
order by ALG.time_stamp asc) b
where rownum <= 1
order by rownum asc
/
Is this the correct way to do it?� I wish I could check the results between the SS2K5 db and the Oracle db but I don't have access to the SS db and even if I did, the data sets are very different.
Anyway, just wanted to know if I was on the right track or am I totally off-base here.
tia
--
mohammed
--
http://www.freelists.org/webpage/oracle-l
Received on Wed Oct 22 2008 - 20:56:43 CDT