쿼리문 합계 질문드립니다.

쿼리문 합계 질문드립니다.

QA

쿼리문 합계 질문드립니다.

본문


$sub_lists = array();
$sub_sqls = array(
    "select count(*) cnt from {$write_table_a} where wr_53='{$row['wr_53']}' and NOT wr_7 IN ('9') AND REPLACE(wr_45, ',', '') > 0 and wr_29 between '{$stx1}' and '{$stx2}' group by mb_id",
    "select count(*) cnt from {$write_table_b} where wr_53='{$row['wr_53']}' and NOT wr_7 IN ('9') AND REPLACE(wr_45, ',', '') > 0 and wr_29 between '{$stx1}' and '{$stx2}' group by mb_id",
    "select count(*) cnt from {$write_table_a} where wr_53='{$row['wr_53']}' and NOT wr_7 IN ('9') AND REPLACE(wr_45, ',', '') > 0 AND REPLACE(wr_45, ',', '') <= 1540000 and wr_29 between '{$stx1}' and '{$stx2}' group by mb_id",
    "select count(*) cnt from {$write_table_b} where wr_53='{$row['wr_53']}' and NOT wr_7 IN ('9') AND REPLACE(wr_45, ',', '') > 0 AND REPLACE(wr_45, ',', '') <= 1540000 and wr_29 between '{$stx1}' and '{$stx2}' group by mb_id",
    "select count(*) cnt from {$write_table_a} where wr_53='{$row['wr_53']}' and NOT wr_7 IN ('9') AND REPLACE(wr_45, ',', '') > 1540000 AND REPLACE(wr_45, ',', '') <= 3600000 and wr_29 between '{$stx1}' and '{$stx2}' group by mb_id",
    "select count(*) cnt from {$write_table_b} where wr_53='{$row['wr_53']}' and NOT wr_7 IN ('9') AND REPLACE(wr_45, ',', '') > 1540000 AND REPLACE(wr_45, ',', '') <= 3600000 and wr_29 between '{$stx1}' and '{$stx2}' group by mb_id",
    "select count(*) cnt from {$write_table_a} where wr_53='{$row['wr_53']}' and NOT wr_7 IN ('9') AND REPLACE(wr_45, ',', '') > 3600000 and wr_29 between '{$stx1}' and '{$stx2}' group by mb_id",
    "select count(*) cnt from {$write_table_b} where wr_53='{$row['wr_53']}' and NOT wr_7 IN ('9') AND REPLACE(wr_45, ',', '') > 3600000 and wr_29 between '{$stx1}' and '{$stx2}' group by mb_id"
  );
foreach ($sub_sqls as $sub_sql) {
    $sub_list = array();
    $sub_result = sql_query($sub_sql, true);
    while ($sub_row = sql_fetch_array($sub_result)) {
        $sub_list[] = $sub_row;
    }
    $sub_lists[] = $sub_list;
}
$set_count_all        = count(array_merge($sub_lists[0], $sub_lists[1]));
$set_count_under    = count(array_merge($sub_lists[2], $sub_lists[3]));
$set_count_154        = count(array_merge($sub_lists[4], $sub_lists[5]));
$set_count_360        = count(array_merge($sub_lists[6], $sub_lists[7]));

단순하게

$set_count_all 의 카운트는

$set_count_under+ $set_count_154+$set_count_360        
의 합계가 나와야 하는데
 $set_count_all의 카운트 수가 더 적습니다.

왜 카운트 수가 맞질 않을까요?

이 질문에 댓글 쓰기 :

답변 2

답변을 작성하시기 전에 로그인 해주세요.
전체 59,282
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT