쿼리문 합계 질문드립니다.
본문
$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의 카운트 수가 더 적습니다.
왜 카운트 수가 맞질 않을까요?
!-->
답변을 작성하시기 전에 로그인 해주세요.