Problem: Table ST with column aa, ab, ac, etc. has column ay pointing to another row in table ST where aa = xy.
az also matches to aa in different row in ST.
(sometimes xy and az are filled and sometimes not).
The result table has to show:
a.aa, a.ab, a.ac, b.xx (c.ab(xy = aa) or ' '),
(c.ab(xz = xz) or space).
I can't figure out what to do... please help
I tried:
Select a.aa, a.ab, a.ac, b.xx
case xy
when = ' ' then ' ' else
select c.ab from ST C where
c.aa = a.xy
end case
, case xz
when = ' ' then ' ' else
select c.ab from ST C where
c.aa = a.xz
end case
from ST a, SX b
and ------------------------------------
Select a.aa, a.ab, a.ac, b.xx
fto = xy
case
when fto = ' ' then ' ' else
select c.ab from ST C where
c.aa = fto
end case
ffr = xz
, case
when ffr = ' ' then ' ' else
select c.ab from ST C where
c.aa = ffr
end case
from ST a, SX b
-----------------------------------
SELECT DISTINCT * FROM ST, SX
CASE yz
WHEN ' ' THEN ' '
ELSE
SELECT * FROM ST c
WHERE C.aa = a.xy
END
from ST A, SX b
----------------------------------------
a million other variations...
az also matches to aa in different row in ST.
(sometimes xy and az are filled and sometimes not).
The result table has to show:
a.aa, a.ab, a.ac, b.xx (c.ab(xy = aa) or ' '),
(c.ab(xz = xz) or space).
I can't figure out what to do... please help
I tried:
Select a.aa, a.ab, a.ac, b.xx
case xy
when = ' ' then ' ' else
select c.ab from ST C where
c.aa = a.xy
end case
, case xz
when = ' ' then ' ' else
select c.ab from ST C where
c.aa = a.xz
end case
from ST a, SX b
and ------------------------------------
Select a.aa, a.ab, a.ac, b.xx
fto = xy
case
when fto = ' ' then ' ' else
select c.ab from ST C where
c.aa = fto
end case
ffr = xz
, case
when ffr = ' ' then ' ' else
select c.ab from ST C where
c.aa = ffr
end case
from ST a, SX b
-----------------------------------
SELECT DISTINCT * FROM ST, SX
CASE yz
WHEN ' ' THEN ' '
ELSE
SELECT * FROM ST c
WHERE C.aa = a.xy
END
from ST A, SX b
----------------------------------------
a million other variations...