<div style="text-align:left;"><img src="http://thimg.todayhumor.co.kr/upfile/201611/1479878182c7be800561784b2c9ebdf9f9a75c7c32__mn74924__w232__h119__f8715__Ym201611.jpg" width="232" height="119" alt="vote.JPG" style="border:none;" filesize="8715"></div> <div style="text-align:left;"> <p></p> <p>투표 항목을 담고있는 vote_item 이라는 위의 테이블과</p></div> <div style="text-align:left;"><br></div> <div style="text-align:left;"><img src="http://thimg.todayhumor.co.kr/upfile/201611/1479878198f4405dbd0c4d42fc9cb0684dcdd26071__mn74924__w208__h99__f7474__Ym201611.jpg" width="208" height="99" alt="vote_join.JPG" style="border:none;" filesize="7474"></div> <p>어느 학생이 어느 투표에 몇번 항목을 체크했다라는 정보를 담고있는 vote_join 이라는 테이블을 가지고 내가 원하는 투표(vote_id로) 의 항목마다 몇명이 투표했는지를 알고싶어서 쿼리문을 짜는데</p> <div class="colorscripter-code" style="color:#010101;overflow:auto;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;"> <table class="colorscripter-code-table" style="margin:0px;padding:0px;border:;background-color:#fafafa;" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:6px;border-right:2px solid rgb(229,229,229);"> <div style="margin:0px;padding:0px;text-align:right;color:#666666;line-height:130%;"> <div style="line-height:130%;">1</div> <div style="line-height:130%;">2</div> <div style="line-height:130%;">3</div> <div style="line-height:130%;">4</div> <div style="line-height:130%;">5</div> <div style="line-height:130%;">6</div> <div style="line-height:130%;">7</div></div></td> <td style="padding:6px 0px;"> <div style="margin:0px;padding:0px;color:#010101;line-height:130%;"> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:#ff3399;">select</span> a.vote_id as vote_id,a.item_no as item_no</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> ,b.item as item,b.image as image,count(<span style="color:#0099cc;">*</span>) as count</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:#ff3399;">from</span> vote_join a, vote_item b</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:#ff3399;">where</span> a.vote_id <span style="color:#0099cc;">=</span> 1</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> and a.vote_id<span style="color:#0099cc;">=</span>b.vote_id</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> and a.item_no <span style="color:#0099cc;">=</span> b.item_no</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> group <span style="color:#ff3399;">by</span> a.item_no, a.vote_id, b.item,b.image</div> <div style="padding:0px 6px;line-height:130%;white-space:pre;"> <span style="color:#ff3399;">order</span> <span style="color:#ff3399;">by</span> item_no asc</div></div> <div style="text-align:right;font-size:9px;font-style:italic;margin-top:-13px;margin-right:5px;"><a style="color:#e5e5e5;text-decoration:none;" href="http://colorscripter.com/info#e" target="_blank">Colored by Color Scripter</a></div></td> <td style="padding:0px 2px 4px 0px;vertical-align:bottom;"><span style="text-decoration:none;padding:1px;font-size:9px;background-color:#e5e5e5;"><a style="text-decoration:none;" href="http://colorscripter.com/info#e" target="_blank">cs</a></span></td></tr></tbody></table></div> <div class="colorscripter-code" style="color:#010101;overflow:auto;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;"> <p>이렇게 작성하니 count가 그냥 전체적으로 동일하게 나오더라구요... group화를 잘못시킨거같은데</p> <p>제대로 시키려면 어떻게해야하나요..?</p></div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.