답변 4개
채택된 답변
+20 포인트
답변에 대한 댓글 3개
�
유기농감자
3년 전
답변 감사합니다. 서브쿼리를 어떻게 짜야할지 감이 전혀 안 잡혀서요.. 어떤 식으로 해야할까요?
�
하틴
3년 전
mysql gruop by max 라고 구글링해보시면 비슷한 내용이 많이 나오는데 참고해보시면 될 것 같아요!
http://jason-heo.github.io/mysql/2014/03/05/find-max-row.html
https://helloino.tistory.com/120
https://bamdule.tistory.com/219
http://jason-heo.github.io/mysql/2014/03/05/find-max-row.html
https://helloino.tistory.com/120
https://bamdule.tistory.com/219
�
유기농감자
3년 전
해결했습니다! 5건만 조회하면 돼서 성능은 어떨지 모르겠지만..
SELECT t1.*
FROM (
SELECT wr_id, mb_no, count(*) as cnt
FROM g5_write_...
GROUP BY wr_id, mb_no
) t1
INNER JOIN
(
select mb_no,max(cnt) as max from (
SELECT wr_id, mb_no, count(*) as cnt
FROM g5_write_...
GROUP BY wr_id, mb_no
) c
GROUP BY mb_no
) t2
ON t1.mb_no = t2.mb_no AND t1.cnt = t2.max;
;
감사합니다!
SELECT t1.*
FROM (
SELECT wr_id, mb_no, count(*) as cnt
FROM g5_write_...
GROUP BY wr_id, mb_no
) t1
INNER JOIN
(
select mb_no,max(cnt) as max from (
SELECT wr_id, mb_no, count(*) as cnt
FROM g5_write_...
GROUP BY wr_id, mb_no
) c
GROUP BY mb_no
) t2
ON t1.mb_no = t2.mb_no AND t1.cnt = t2.max;
;
감사합니다!
댓글을 작성하려면 로그인이 필요합니다.
3년 전
</p>
<p>select wr_id, mb_no, count(*) from g5_write.... group by wr_id, mb_no order by count(*) desc limit 0,1; </p>
<p>
정렬을 count(*) desc 하시고 limit 0,1 해서 최상위 한개만 가져오심 됩니다
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
3년 전
이걸 사용하시면 됩니다.
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인