I'm trying to convert the following MS SQL to Oracle PS/SQL but not getting anywhere. I'm having problems converting the top N part of the query to use Oracle's ROWNUM function. That part of the query is already a sub-query and nesting 2 sub-queries is giving me a problem. Any suggestions?
Here are my tables:
TABLE & TABLE2 (the same table)
Id Record_Id Date
12 556 3/26/06
13 556 3/28/06
14 556 4/05/06
TABLE3
Id Record_Num
556 789878
Here are the results that I want:
NUM START COLUMN
556 3/26/06 3/28/06
Here are my tables:
TABLE & TABLE2 (the same table)
Id Record_Id Date
12 556 3/26/06
13 556 3/28/06
14 556 4/05/06
TABLE3
Id Record_Num
556 789878
Here are the results that I want:
NUM START COLUMN
556 3/26/06 3/28/06
Code:
select NUM,
START,
COLUMN
from (
select B.RECORD_NUM NUM,
A.DATE START,
(select TOP 1
T.THE_VAL
from TABLE T
where T.RECORD_ID = B.ID
and T.DATE >= A.DATE
order by T.DATE ) 'COLUMN',
from TABLE2 A
join TABLE3 B on A.RECORD_ID = B.ID
) tb1