일반 조인을 안시조인으로 0 4 582

by 준일정 [SQL Query] sql [2018.05.23 15:26:14]


asdasd.GIF (4,481Bytes)

어떤식으로 해야 하나요? 

 

select 
    b.materialcode, b.materialname
from 
    orders a inner join material b on 
    a.dealercode=b.dealercode and
    a.materialcode=b.materialcode and 
    a.stockinday between '20180501' and '20180523' and 
    a.storecode not in('9999') and
    a.storecode='2001' ; 

 

이렇게 하면 중복된 데이터가 나옵니다 ㅠㅠ 어떻게 해야 하나요?

by 우리집아찌 [2018.05.23 15:29:33]
-- group by
select 
    b.materialcode, b.materialname
from 
    orders a inner join material b on 
    a.dealercode=b.dealercode and
    a.materialcode=b.materialcode and 
    a.stockinday between '20180501' and '20180523' and 
    a.storecode not in('9999') and
    a.storecode='2001'
group by  b.materialcode, b.materialname   ; 


-- distinct
select distinct
    b.materialcode, b.materialname
from 
    orders a inner join material b on 
    a.dealercode=b.dealercode and
    a.materialcode=b.materialcode and 
    a.stockinday between '20180501' and '20180523' and 
    a.storecode not in('9999') and
    a.storecode='2001' ;
    

 


by 준일정 [2018.05.23 22:53:26]

답변 감사합니다!!!!


by 마농 [2018.05.23 15:49:29]

제목과 질문이 일치하지 않네요?
제목은 조인인데 내용은 중복제거네요?


by 마농 [2018.05.23 18:02:56]

아하!
이미지가 원본 쿼리고 텍스트가 수정쿼리군요?
원본쿼리에 있던 조건이 수정 쿼리에 누락되었네요. (a.dealercode = '1531')

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