[답변]oracel 9i -> 8i 문제점 0 0 1,635

by 윤정희 [2006.06.12 16:26:09]


현영님 다시 한번 부탁 드립니다.

 

=========================== 전체 문장입니다. ========================

에러 내용은 ORA-00904: invalid column name

에러 난곳에 표시 합니다.

 

select  aa.gbm gbm,
                aa.country_code country_code,
                aa.vd_cnt vd_cnt,
                aa.vd_war_cnt vd_war_cnt,
                round(aa.vd_war_cnt * 100 / aa.vd_cnt,1) vd_war_p,
                aa.vd_self_cnt vd_self_cnt,
                round(aa.vd_self_cnt * 100 / aa.vd_cnt,1) vd_self_p,
                aa.vd_audit_cnt vd_audit_cnt,
                round(aa.vd_audit_cnt * 100 / aa.vd_cnt,1) vd_audit_p,
                aa.vd_eco_cnt vd_eco_cnt,
                round(aa.vd_eco_cnt * 100 / aa.vd_cnt,1) vd_eco_p,
                aa.mt_cnt mt_cnt,
                aa.mt_add_cnt mt_add_cnt,
                round((aa.mt_pass_cnt + aa.mt_prog_cnt) * 100 / aa.mt_cnt,1) mt_add_p,
                aa.mt_pass_cnt mt_pass_cnt,
                round(aa.mt_pass_cnt * 100 / aa.mt_cnt,1) mt_pass_p,
                aa.mt_ng_cnt mt_ng_cnt,
                round(aa.mt_ng_cnt * 100 / aa.mt_cnt,1) mt_ng_p,
                aa.mt_prog_cnt mt_prog_cnt,
                round(aa.mt_prog_cnt * 100 / aa.mt_cnt,1) mt_prog_p
          from  (
                select  decode(flag,'1',gbm,'2',gbm)  gbm,
                        decode(flag,'1',country_code,'2','Total')  country_code,
                        sum(vd_cnt) vd_cnt,
                        sum(vd_war_cnt) vd_war_cnt,
                        sum(vd_self_cnt) vd_self_cnt,
                        sum(vd_audit_cnt) vd_audit_cnt,
                        sum(vd_eco_cnt) vd_eco_cnt,
                        sum(mt_cnt) mt_cnt,
                        sum(mt_pass_cnt + mt_prog_cnt) mt_add_cnt,
                        sum(mt_pass_cnt) mt_pass_cnt,
                        sum(mt_ng_cnt) mt_ng_cnt,
                        sum(mt_prog_cnt) mt_prog_cnt
                   from (
                        select  gbm,
                                decode(imptvdhd.country_code,'KR','Local','Oversea') country_code,
                          count(distinct vdim.vendor_code) vd_cnt,
                          count(distinct vdaf.hq_code) vd_war_cnt,
                  count(distinct(decode(vdmt.audit_gbm,'No Audit',vdmt.vendor_code,'Small',vdmt.vendor_code,'Semi',vdmt.vendor_code,'Etc',vdmt.vendor_code,'Global',vdmt.vendor_code,'Green Partner',decode(z.flag,'Y',vdmt.vendor_code),decode(g.answer_grade,'Y',g.hq_code,'N',g.hq_code)))) vd_self_cnt,
                  count(distinct(decode(vdmt.audit_gbm,'No Audit',vdmt.vendor_code,'Small',vdmt.vendor_code,'Semi',vdmt.vendor_code,'Etc',vdmt.vendor_code,'Global',vdmt.vendor_code,'Green Partner',decode(z.flag,'Y',vdmt.vendor_code),decode(h.sec_confirm_grade,'PASS',h.hq_code)))) vd_audit_cnt,
                          count(distinct(decode(vdhd.confirm_flag,'Y',vdhd.hq_code))) vd_eco_cnt,
                          count(*) mt_cnt,
                          count(decode(vdbh.confirm_flag,'Y',1)) mt_pass_cnt,
                          count(decode(vdbh.confirm_flag,'N',1)) mt_ng_cnt,
                          count(decode(decode(vdbh.confirm_flag,null,vdbh.result),'PASS',vdbh.submit_date,'FAIL',vdbh.submit_date)) mt_prog_cnt
                          from  (select gbm,vendor_code,item_code
                                   from egrptvdim
                                 where sec_company in ('C100','C110','C130')
                                    and item_status <> 'D'
                                    and (ipc_flag is null or ipc_flag = ' ')
                                  group by gbm,vendor_code,item_code) vdim,
                               egrptvdhd vdhd, egrptvdbh vdbh, egrptvdmt vdmt,imptvdhd imptvdhd,
                 (SELECT x.HQ_CODE      ,
                         x.ANSWER_GRADE
                    FROM EGRPTEQSS x,
                         (

--현영님 수정 부분
    SELECT HQ_CODE,

         DECODE(A,1,
             (SELECT MAX(b.BASIC_SEQ) FROM EGRPTEQSS b

                 WHERE b.ANSWER_GRADE = 'Y' AND b.HQ_CODE = a.HQ_CODE),
             (SELECT MAX(b.BASIC_SEQ) FROM EGRPTEQSS b

                 WHERE b.ANSWER_GRADE = 'N' AND b.HQ_CODE = a.HQ_CODE)) B
FROM (
 SELECT HQ_CODE,
        SIGN(SUM(DECODE(ANSWER_GRADE,'Y',1,0))) A
   FROM EGRPTEQSS
 WHERE ANSWER_GRADE IS NOT NULL
GROUP BY HQ_CODE
) A

--- 여기까지..

) y
                  
     WHERE x.HQ_CODE   = y.HQ_CODE
                     AND x.BASIC_SEQ = y.BASIC_SEQ) g,   

                                                        --이부분이 에러입니다.인식못함.
                (select a.hq_code,a.sec_confirm_grade
                    from egrpteqss a ,(select hq_code,max(basic_seq) basic_seq
                                         from egrpteqss
                                        where sec_confirm_grade is not null
                                      group by hq_code ) b
                    where a.hq_code = b.hq_code
                    and a.basic_seq = b.basic_seq
                    and a.sec_confirm_grade = 'PASS') h,
             (select vdaf.hq_code , 'Y' flag
                 from egrptvdaf vdaf, egrptvdmt vdmt
                where vdaf.document_gubun='G'
                  and vdaf.confirm_flag = 'Y'
                   and vdmt.audit_gbm = 'Green Partner'
                  and vdaf.hq_code = vdmt.vendor_code) z,
                               (select hq_code
                                  from egrptvdaf
                                 where document_gubun='A'
                                   and confirm_flag  ='Y'
                                   and to_char(sysdate, 'YYYYMMDD') between guarantee_from and guarantee_to
                                   group by hq_code) vdaf
                         where vdim.vendor_code = vdhd.hq_code(+)
                           and vdim.vendor_code = vdmt.vendor_code(+)
                           and vdim.vendor_code = vdaf.hq_code(+)
                           and vdim.vendor_code = vdbh.hq_code(+)
                           and vdim.item_code   = vdbh.item_code(+)
                   and vdim.vendor_code = g.hq_code(+)
                   and vdim.vendor_code = h.hq_code(+)
                   and vdim.vendor_code = z.hq_code(+)
                           and vdim.vendor_code = imptvdhd.seller_company(+)
                         group by gbm,decode(imptvdhd.country_code,'KR','Local','Oversea')),
                         (select '1' as flag from dual
                          union all
                          select '2' as flag from dual)
                          group by decode(flag,'1',gbm,'2',gbm),
                                   decode(flag,'1',country_code,'2','Total')
                          order by gbm,country_code
                ) aa

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입