SQL> -- not allowed since my_alias is defined in the inner select
SQL> select dummy from
2 (
3 select dummy col1 from dual my_alias
4 )
5 where my_alias.dummy='X'
6 /
where my_alias.dummy='X'
*
ERROR at line 5:
ORA-00904: "MY_ALIAS"."DUMMY": invalid identifier
SQL>
SQL> --This is allowed: trick here since I aliased the inner select with the same alias
SQL> select dummy from
2 (
3 select dummy from dual my_alias
4 ) my_alias
5 where my_alias.dummy='X'
6 /
D
-
X
drop table tab1 purge;
create table tab1(col1 char(1));
insert into tab1 values('a');
drop table tab2 purge;
create table tab2(col2 char(1));
insert into tab2 values('a');
select a.col1, a.col2 from tab1 a, tab2 a
where a.col1=a.col2
/
SELECT
letter
FROM TableA z
INNER JOIN TableC y ON z.Col1 = y.Col1
INNER JOIN TableB b ON y.Col2 = b.Col2 -- was an a, now b
INNER JOIN TableA w ON z.Col1 = w.Col1 -- x changed to z
INNER JOIN TableD d ON z.Col2 = d.Col2 -- was an a, now d; x changed to z
WHERE letter_type = 15
AND rownum < 6
I am modifying a 3 page sql statement in a legacy application.
What I am showing is a snippet that needs to be fixed.
where should the I add a left parenthesis ?
Please Use a 'XX' to show where it should go.
select letter FROM TableA
where letter =
(select letter from TableA z,
TableC y, TableB a, TableA w, TableD a
where y.Col2 = a.Col2
and z.Col1 = y.Col1
and letter_type = 15) and letter_type = 15
and x.Col2 = a.Col2
and x.Col1 = w.Col1
and rownum < 6)
Where should the 'in' be used to replace the '=' ?
Please use Please Use a 'IN' to show where it should go.
Thanks,