LEFT JOIN, GROUP BY, SUM 복합 퀴리 질문.. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

LEFT JOIN, GROUP BY, SUM 복합 퀴리 질문.. 정보

LEFT JOIN, GROUP BY, SUM 복합 퀴리 질문..

본문

A테이블

--------------------
id          point
1            1000
2            3000
3            3000
4            5000
5            5000
6            3000

B테이블
-------------
id  table
1  a10
1  a10
2  a20
3  a20
4  a30
5  a40
6  a40


이렇게 데이터가 있습니다.. b테이블을 id 중복일수도 있습니다.
최종적으로
데이터를 2가지 형태로
point
20000
-------------- 
table point
a10  1000
a20  6000
a30  5000
a40  8000

이렇게 뽑고 싶은데.. 도저희 내 능력으로 안되더라구요.
WITH ROLLUP 이용하면 된다고 하지만 그것도 안만 해도 안되고..

힌트 정도만 알려주셔도 너무 감사하겠습니다.
  • 복사

( select a.* , ( select sum(co_count) as co_count from g4_qa_choose where mb_id=a.mb_id and bo_table = 'g4_qa' ) as q_co_count from `g4_write_g4_qa` a where wr_parent = '184110' and wr_8 != '' and wr_is_comment = 1 and CONVERT(wr_7, UNSIGNED) >= 5 group by wr_content having max(wr_7) order by CONVERT(wr_7, UNSIGNED) desc limit 3 )

1055 : Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'sir.a.wr_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

error file : /15sir/bbs/board.php