join sum() 합산 질문...
본문
3개 join
select a.mb_name, b.mb_id, c.mb_id, count(*) as cnt , sum(b.wr_31) as totb, sum(c.wr_31) as totc
from g5_member a
left join g5_write_csorder b on a.mb_id = b.mb_id
left join g5_write_cscenter c on a.mb_id = c.mb_id
where b.wr_29 between '{$stx1}' and '{$stx2}' and b.wr_50 like '%{$stx7}%' and NOT b.wr_54 IN ('exchange') and NOT b.wr_7 IN ('4') and
c.wr_29 between '{$stx1}' and '{$stx2}' and c.wr_50 like '%{$stx7}%'
group by a.mb_name, b.mb_id ORDER BY totb DESC
2개 join (cscenter) sum()값이 정상적임
회원 닉네임때문에 member와 join
select a.mb_name, b.mb_id,count(*) as cnt , sum(b.wr_31) as totb
from g5_member a
left join g5_write_cscenter b on a.mb_id = b.mb_id
where b.wr_29 between '{$stx1}' and '{$stx2}' and b.wr_50 like '%{$stx7}%'
group by a.mb_name, b.mb_id ORDER BY totb DESC
2개 join (csorder) sum()값이 정상적임
회원 닉네임때문에 member와 join
select a.mb_name, b.mb_id,count(*) as cnt , sum(b.wr_31) as totb
from g5_member a
left join g5_write_csorder b on a.mb_id = b.mb_id
where b.wr_29 between '{$stx1}' and '{$stx2}' and b.wr_50 like '%{$stx7}%' and NOT b.wr_54 IN ('exchange') and NOT b.wr_7 IN ('4')
group by a.mb_name, b.mb_id ORDER BY totb DESC
아래에 각각 cscenter와 csorder의 sum()값은 정상인데
2개를 함께한 가장 위 sum()값은 상황에 따라 너무 다르게 변하네요...
왜 변하는지를 알면 찾아보고 수정하거나 구글링을 해 볼텐데.. 이유조차 모르겠어서.. 답답합니다.
!-->!-->!-->
답변을 작성하시기 전에 로그인 해주세요.