Hello All Sybase SQL Guru's,
I need some assistance with a correlated subquery. Right now I have a select statement within a stored procedure that has the tables joined with an outer join and few conditions in the where clause. I need to add more conditions to the where clause and the only way I have been able to get close to producing the results is by removing the outer joins and using union all on slightly modified select statements with just different where conditions.
Below is an example of what I have and then below that is what I need. Please Advise!! Thanks in advance for your time and efforts!
NOW:
select a.field1
,a.field2
,b.field1
,c.field1
from tab1 a, tab2 b, tab3 c
where b.fieldX =* a.fieldY + a.fieldZ
and c.fieldA =* a.fieldB + a.fieldC
and b.whatever is null
and c.whatever is null
NEEDED:
select a.field1
,a.field2
,(select b.field1 from tab2 b where...)
,(select c.field1 from tab3 c where...)
from tab1 a
I need some assistance with a correlated subquery. Right now I have a select statement within a stored procedure that has the tables joined with an outer join and few conditions in the where clause. I need to add more conditions to the where clause and the only way I have been able to get close to producing the results is by removing the outer joins and using union all on slightly modified select statements with just different where conditions.
Below is an example of what I have and then below that is what I need. Please Advise!! Thanks in advance for your time and efforts!
NOW:
select a.field1
,a.field2
,b.field1
,c.field1
from tab1 a, tab2 b, tab3 c
where b.fieldX =* a.fieldY + a.fieldZ
and c.fieldA =* a.fieldB + a.fieldC
and b.whatever is null
and c.whatever is null
NEEDED:
select a.field1
,a.field2
,(select b.field1 from tab2 b where...)
,(select c.field1 from tab3 c where...)
from tab1 a