SQL 未明确定义列
insertintoAGL89M12selectNVL(A31BRCH,D.A89BRCH)fromAGL31M00eFULLOUTERJOIN(SELECTA89GLN...
insert into AGL89M12
select
NVL(A31BRCH,D.A89BRCH)
from AGL31M00 e
FULL OUTER JOIN
(SELECT A89GLNO,A89BRCH,A89CCYC, ABS(AMNT) A89AMNT,(CASE WHEN AMNT >=0 THEN 'DR' ELSE 'CR' END ) A89DRCR FROM
(SELECT A89GLNO,A89BRCH,A89CCYC,SUM(CASE WHEN A89DRCR = 'DR' THEN A89AMNT ELSE (-1) * A89AMNT END) AMNT FROM AGL89M01 GROUP BY A89GLNO,A89BRCH,A89CCYC) A)
D ON e.A31BRCH = D.A89BRCH
AND e.A31CCYC = D.A89CCYC
AND TRIM(CASE WHEN e.A31CUCD =' ' THEN e.A31ACIT ELSE e.A31CUCD END) = TRIM(D.A89GLNO)
LEFT JOIN (select refno,
(case
when bchtype = '2' then
parent
else
refno
end )sbch
from TABCHM01) A ON e.A31BRCH = A.REFNO
;
commit;
外边一起执行FULL OUTER JOIN 下select 没问题 执行最外层的 就有问题 报未明确定义列 展开
select
NVL(A31BRCH,D.A89BRCH)
from AGL31M00 e
FULL OUTER JOIN
(SELECT A89GLNO,A89BRCH,A89CCYC, ABS(AMNT) A89AMNT,(CASE WHEN AMNT >=0 THEN 'DR' ELSE 'CR' END ) A89DRCR FROM
(SELECT A89GLNO,A89BRCH,A89CCYC,SUM(CASE WHEN A89DRCR = 'DR' THEN A89AMNT ELSE (-1) * A89AMNT END) AMNT FROM AGL89M01 GROUP BY A89GLNO,A89BRCH,A89CCYC) A)
D ON e.A31BRCH = D.A89BRCH
AND e.A31CCYC = D.A89CCYC
AND TRIM(CASE WHEN e.A31CUCD =' ' THEN e.A31ACIT ELSE e.A31CUCD END) = TRIM(D.A89GLNO)
LEFT JOIN (select refno,
(case
when bchtype = '2' then
parent
else
refno
end )sbch
from TABCHM01) A ON e.A31BRCH = A.REFNO
;
commit;
外边一起执行FULL OUTER JOIN 下select 没问题 执行最外层的 就有问题 报未明确定义列 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询