select 에서... 글쓴이가 아니라 wr_41 동일값으로 체크할 수 있나요? 채택완료
</p>
<p> $write_table = $g5['write_prefix'] . $bo_table;
$sql = "
select a.mb_id, b.mb_name, count(*) as cnt , sum(a.wr_31) as tot
from {$write_table} a
left outer join {$g5['member_table']} b on a.mb_id = b.mb_id
where wr_29 between '{$stx1}' and '{$stx2}'
group by a.mb_id, b.mb_name ORDER BY tot DESC
";
$result = sql_query($sql);
while ($row = sql_fetch_array($result)) {
$sum_count ++</p>
<p>
위 코드는 기간내 작성자를 검색해서 wr_31값을 합산하여 순위를 뿌려주는 코드입니다.
작성자가 아닌 wr_41값을 비교해서 뿌릴려면 어떻게 바꿔야 할까요?
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
4년 전
group by a.mb_id, b.mb_name
이건
group by a.mb_id
이렇게만 하셔도 됩니다.
원하신는 건
group by a.wr_41
이렇게 바꾸시면 될 듯합니다.
로그인 후 평가할 수 있습니다
답변에 대한 댓글 5개
�
4년 전
�
4년 전
값이 이전값과 동일합니다.
<td class="td_c"><?php echo $sum_count ?>위</td>
<td class="td_c"><?php echo $row['wr_41'] ?></td>
<td class="td_c"><?php echo $row['mb_name'] ?></td>
<td class="td_c"><?php echo $row['cnt'] ?> 명</td>
<td class="td_r"><?php echo number_format($row['tot']) ?>원</td>
이렇게 찍어봐도 wr_41에... 작성자가 나옵니다.
<td class="td_c"><?php echo $sum_count ?>위</td>
<td class="td_c"><?php echo $row['wr_41'] ?></td>
<td class="td_c"><?php echo $row['mb_name'] ?></td>
<td class="td_c"><?php echo $row['cnt'] ?> 명</td>
<td class="td_r"><?php echo number_format($row['tot']) ?>원</td>
이렇게 찍어봐도 wr_41에... 작성자가 나옵니다.
�
4년 전
select a.wr_41, b.mb_name, count(*) as cnt , sum(a.wr_31) as tot
from {$write_table} a
left outer join {$g5['member_table']} b on a.mb_id = b.mb_id
where wr_29 between '{$stx1}' and '{$stx2}'
group by a.wr_41, b.mb_name ORDER BY tot DESC
말씀처럼 이렇게 해보고
select a.wr_41, b.mb_name, count(*) as cnt , sum(a.wr_31) as tot
from {$write_table} a
left outer join {$g5['member_table']} b on a.wr_41= b.mb_id
where wr_29 between '{$stx1}' and '{$stx2}'
group by a.wr_41, b.mb_name ORDER BY tot DESC
이렇게도 해봤습니다.
from {$write_table} a
left outer join {$g5['member_table']} b on a.mb_id = b.mb_id
where wr_29 between '{$stx1}' and '{$stx2}'
group by a.wr_41, b.mb_name ORDER BY tot DESC
말씀처럼 이렇게 해보고
select a.wr_41, b.mb_name, count(*) as cnt , sum(a.wr_31) as tot
from {$write_table} a
left outer join {$g5['member_table']} b on a.wr_41= b.mb_id
where wr_29 between '{$stx1}' and '{$stx2}'
group by a.wr_41, b.mb_name ORDER BY tot DESC
이렇게도 해봤습니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인전체 질문 목록
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
채택
답변대기
답변대기
답변대기
답변대기
채택
채택
답변대기
답변대기
답변대기
채택
from {$write_table} a
left outer join {$g5['member_table']} b on a.mb_id = b.mb_id
where wr_29 between '{$stx1}' and '{$stx2}'
group by a.wr_41 ORDER BY tot DESC