Background Image

FORUM

2022.08.12 10:22

조건절서브쿼리오류

조회 수 141 추천 수 0 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄


* 질문 등록 시 다음의 내용을 꼭 기입하여 주세요.

OS
 Linux 64bit 등
CUBRID Ver.
11.2
CUBRID TOOL Ver.
sqlgate
응용 환경(API)
 


* CUBRID 응용 오류, SQL 오류 또는 SQL 튜닝 관련된 문의는 반드시 다음의 내용을 추가해 주세요. 비밀글이나 비밀 댓글도 가능합니다.
* 저희가 상황을 이해하고, 재현이 가능해야 알 수 있는 문제들이 많습니다. 가능한 정보/정황들을 부탁합니다.

 

에러 내용 및 재현 방법 재현 가능한 Source와 SQL
관련 테이블(인덱스, 키정보 포함) 정보 CUBRID 홈 디렉토리 아래 log 디렉토리 압축


-------------- 아래에 질문 사항을 기입해 주세요. ------------------------------------------------------------------------

select *
from cg_reg_info t1 left outer join cg_ers_his t2
                                        on t1.lnd_r  = t2.lnd_r
                                       and t1.lnd_no = t2.lnd_no
                                       and t1.app_yr = t2.app_yr
                                       and t1.app_no = t2.app_no
                                       and t1.reg_no = t2.reg_no
                                       and t2.ser_no  =  (select max(ser_no) from cg_ers_his 
                                                     where lnd_r = t1.lnd_r and lnd_no = t1.lnd_no
                                                       and app_yr= t1.app_yr and app_no = t1.app_no
                                                       and reg_no = t1.reg_no 
                                                       and reg_dt = (select max(reg_dt) from cg_ers_his 
                                                                                         where lnd_r = t1.lnd_r and lnd_no = t1.lnd_no
                                                                                       and app_yr= t1.app_yr and app_no = t1.app_no
                                                                                       and reg_no = t1.reg_no)
                                                             )
WHERE t1.app_yr = '2022' AND t1.app_no = '50001'  

 

-----------------------------------------------------------------------------------------------------------------------------------

에러

Cannot use a subquery in join condition clause. 

이 부분 지우면 제대로 실행

and t2.ser_no  =  (select max(ser_no) from cg_ers_his 
                                                     where lnd_r = t1.lnd_r and lnd_no = t1.lnd_no
                                                       and app_yr= t1.app_yr and app_no = t1.app_no
                                                       and reg_no = t1.reg_no 
                                                       and reg_dt = (select max(reg_dt) from cg_ers_his 
                                                                                         where lnd_r = t1.lnd_r and lnd_no = t1.lnd_no
                                                                                       and app_yr= t1.app_yr and app_no = t1.app_no
                                                                                       and reg_no = t1.reg_no)
                                                             )

 

-----------------------------------------------------------------------------------------------------------------------------------

 

where 절에 서브쿼리가 지원이 안되나요????

 

 

select *
from cg_reg_info t1 left outer join cg_ers_his t2
                                        on t1.lnd_r  = t2.lnd_r
                                       and t1.lnd_no = t2.lnd_no
                                       and t1.app_yr = t2.app_yr
                                       and t1.app_no = t2.app_no
                                       and t1.reg_no = t2.reg_no
                                       and t2.ser_no  IN  (1,2
                                                       
                                                             )
WHERE t1.app_yr = '2022' AND t1.app_no = '50001'

 

--> 제대로 실행

 

select *
from cg_reg_info t1 left outer join cg_ers_his t2
                                        on t1.lnd_r  = t2.lnd_r
                                       and t1.lnd_no = t2.lnd_no
                                       and t1.app_yr = t2.app_yr
                                       and t1.app_no = t2.app_no
                                       and t1.reg_no = t2.reg_no
                                       and t2.ser_no  IN  (select ser_no from cg_ers_his  a
                                                     where a.lnd_r = t1.lnd_r and a.lnd_no = t1.lnd_no
                                                       and a.app_yr= t1.app_yr and a.app_no = t1.app_no
                                                       and a.reg_no = t1.reg_no 
                                                       
                                                             )
WHERE t1.app_yr = '2022' AND t1.app_no = '50001'    

 

--> 에러, Cannot use a subquery in join condition clause.                                                                                         

 

 

 

 

 

  • ?
    권호일 2022.08.16 13:36

    안녕하세요.

    CUBRID 11,2에서는 ON절에서 subquery를 아직 지원하지 않고 있습니다.

    문의 주신 쿼리는 분석함수를 사용하여 cg_ers_his 테이블에서 최대 reg_dt와 ser_no에 해당하는 레코드를 1건만 찾아서 cg_reg_info 테이블과 left outer join 하도록 변경하였습니다.

    아래와 같이 변경이 가능하고, 쿼리성능도 더 빨라 질 것으로 예상 됩니다.

    확인 부탁 드리겠습니다.

    감사합니다.



    select *
    from cg_reg_info t1 left outer join
           ( select t2.*
             from ( select t2.*,
                                  ROW_NUMBER() OVER ( PARTITION BY t2.lnd_r, t2.lnd_no, t2.app_yr, t2.app_no, t2.reg_no ORDER BY t2.reg_dt, t2.ser_no DESC ) AS MAX_NUM
                        from cg_ers_his t2
                        where t2.app_yr = '2022' AND t2.app_no = '50001'
                       ) t2
             where t2.MAX_NUM = 1
            ) t2
          on t1.lnd_r = t2.lnd_r
        and t1.lnd_no = t2.lnd_no
        and t1.app_yr = t2.app_yr
        and t1.app_no = t2.app_no
        and t1.reg_no = t2.reg_no
    WHERE t1.app_yr = '2022' AND t1.app_no = '50001'


  1. CUBRID 사용자를 위한 DBeaver 도구 출시 안내

    Date2024.04.23 Byadmin Views119
    read more
  2. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4476
    read more
  3. 정수/정수 결과를 소수로 출력하게 하는법

    Date2022.02.23 Bysuyeon Views198
    Read More
  4. 정수와 정수의 나누기..

    Date2013.10.08 By파란토끼 Views10719
    Read More
  5. 제로보드 4 이용중인데 최신게시물 불러오기에서 힘드네요

    Date2009.06.03 By헬리 Views11
    Read More
  6. 제약조건 비활성화

    Date2009.10.28 By삽질중 Views9612
    Read More
  7. 제약조건을 어떻게 설정하나요.?

    Date2010.05.02 By큐돌이 Views11637
    Read More
  8. 제품소개 FAQ를 읽고 질문 드립니다

    Date2011.09.02 By유니콘 Views8102
    Read More
  9. 조건절 in 에 들어가는 순서대로 뽑고 싶습니다.

    Date2023.02.15 By구르마도리 Views92
    Read More
  10. 조건절서브쿼리오류

    Date2022.08.12 Byozro Views141
    Read More
  11. 조건절에서 ' '와 ''이 동일하게 작용합니다.

    Date2010.09.01 Byjjobi Views8810
    Read More
  12. 조인 관련 질문입니다.

    Date2009.12.16 By지니보이 Views9857
    Read More
  13. 조인 업데이트 구문 문의

    Date2010.04.09 By초보 Views13972
    Read More
  14. 조회쿼리 시간단축

    Date2023.06.30 Byleeee Views98
    Read More
  15. 존재하지 않는 대상조회시 결과값이 나오는 현상 문의

    Date2021.11.16 Byhajun Views203
    Read More
  16. 죄송하게도 loadjava 다시 질문 올립니다. ^.^;

    Date2016.07.01 By보물섬 Views10751
    Read More
  17. 주가 데이터를 큐브리드로 수집하려고 하는데요.. 큐브리드가 부하를 어느정도까지 버틸 수 있을까요

    Date2010.12.06 By푸훗 Views8266
    Read More
  18. 중국어 XP에서는 큐브리드 ODBC를 사용 할 수 없나요??

    Date2009.12.10 By푸른잔디 Views10178
    Read More
  19. 중복데이터 제거 방법 좀 알려주세요.

    Date2009.05.26 By김경아 Views26574
    Read More
  20. 중복생성 결과로 인한 질문드립니다.

    Date2017.04.03 Byssamdib Views9672
    Read More
  21. 증분백업 복구가 잘 않되고 있습니다.

    Date2011.11.08 Byreerror Views11508
    Read More
  22. 증분백업이 안됩니다.

    Date2020.11.19 ByPhilip Park Views275
    Read More
Board Pagination Prev 1 ... 150 151 152 153 154 155 156 157 158 159 ... 200 Next
/ 200

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales