쿼리문 where에 sum을 사용하지 못하나요?

쿼리문 where에 sum을 사용하지 못하나요?

QA

쿼리문 where에 sum을 사용하지 못하나요?

답변 1

본문


    select a.mb_id, b.mb_name, sum(a.wr_23) as tot
      from {$write_table} a
               left outer join {$g5['member_table']} b on a.mb_id = b.mb_id
     where a.wr_29 between '{$stx1}' and '{$stx2}' and sum(a.wr_23) < 1540000
     group by a.mb_id, b.mb_name
     ORDER BY tot DESC

 


    select a.mb_id, b.mb_name, sum(a.wr_23) as tot
      from {$write_table} a
               left outer join {$g5['member_table']} b on a.mb_id = b.mb_id
     where a.wr_29 between '{$stx1}' and '{$stx2}' and tot < 1540000
     group by a.mb_id, b.mb_name
     ORDER BY tot DESC

 

wr_23이 배열로 되어 있어서 이 값을 합한 금액을 뽑아야 합니다.

 

wr_23을 합한 값이 154만원 이하만 가져오고 싶은데..

sum을 사용하지 못할때는 어떻게 해야 하는지 궁금합니다.

이 질문에 댓글 쓰기 :

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
  • 질문이 없습니다.
전체 0
© SIRSOFT
현재 페이지 제일 처음으로