Dieter!
This is view!
REPLACE VIEW Vdbname.View1 AS
LOCKING ROW FOR ACCESS
SEL D.PLN_ID,D.CLT_ID,D.CLT_RET_AGE, D.CO_CLT_RET_AGE, D.CO_CLT_WD, D.CTCT_WD,D.PLNDT_WD,
D.TOT_AST,D.TOT_HLD_AST,D.EST_HLD_AST,D.OPEN_BAL,D.HSHLD_EMP_INC,
D.HSHLD_NET_WORTH,D.LBLTS, D.LFSTL_ASTS, D.IN_AFTR_OUTRCH_BAL,D.OUT_AFTR_OUTRCH_BAL,D.TX_MTH_WD,
CASE WHEN D.TOT_AST IS NULL AND OPEN_BAL IS NULL THEN NULL ELSE D.INDCTR_WD END INDCTR_WD
FROM
(SELECT
COALESCE(T1.PLN_ID ,T2.PLN_ID ) PLN_ID,
COALESCE(T1.CLT_ID ,T2.CLT_ID ) CLT_ID,
COALESCE(T1.CLT_RET_AGE,T2.CLT_RET_AGE) CLT_RET_AGE,
COALESCE(T1.CO_CLT_RET_AGE,T2.CO_CLT_RET_AGE) CO_CLT_RET_AGE,
COALESCE(T1.CO_CLT_WD,T2.CO_CLT_WD) CO_CLT_WD,
COALESCE(T1.CTCT_WD, T2.CTCT_WD) CTCT_WD,
COALESCE(T1.PLNDT_WD, T2.PLNDT_WD) PLNDT_WD,
COALESCE(T1.QL_AST ,T2.NON_QL_AST ) TOT_AST,
COALESCE(T1.QL_ASTS_HLD ,T2.NON_QL_TAX_AST_HLD ) TOT_HLD_AST,
COALESCE(T1.QL_EST_HLD_AST ,T2.NON_QL_EST_HLD_AST) EST_HLD_AST ,
COALESCE(T1.QL_OPEN_BAL,T2.NON_QL_OPEN_BAL ) OPEN_BAL ,
T1.HSHLD_EMP_INC,
T1.HSHLD_NET_WORTH,
T1.LBLTS,
T1.LFSTL_ASTS,
COALESCE(T1.IN_AFTR_OUTRCH_BAL_QL, T2.IN_AFTR_OUTRCH_BAL_NON_QL) IN_AFTR_OUTRCH_BAL,
COALESCE(T1.OUT_AFTR_OUTRCH_BAL_QL, T2.OUT_AFTR_OUTRCH_BAL_NON_QL) OUT_AFTR_OUTRCH_BAL,
COALESCE(T1.TX_MTH_WD, T2.TX_MTH_WD) TX_MTH_WD,
CASE
WHEN T1.QL_OPEN_BAL IS NOT NULL THEN EF.ROW_WD
WHEN T1.QL_AST IS NOT NULL THEN EF.ROW_WD
ELSE AB.ROW_WD END INDCTR_WD
FROM
(SELECT CM.ROW_WD FROM Tdbname.TBL1 CM WHERE CM."TYPE"='NON_QL_FLG' AND CM.VAL ='NON_QLIFIED') AB,
(SELECT CM.ROW_WD FROM Tdbname.TBL1 CM WHERE CM."TYPE"='QL_FLG' AND CM.VAL ='QLIFIED') EF,
Tdbname.tbl T1 FULL JOIN Tdbname.tbl T2 ON 1=2) D;
↧