1

GROUP_CONCATこのクエリでどのように適用しますか?

クエリ

SELECT WEEK(cpd.added_date) AS week_no,COUNT(cpd.result) AS death_count
FROM cron_players_data cpd WHERE cpd.player_id = 81
AND cpd.result = 2 AND cpd.status = 1
GROUP BY WEEK(cpd.added_date);

クエリ出力結果画面

ここに画像の説明を入力

結果必須

23,24,25 AS week_no 2,3,1 AS death_count  
4

2 に答える 2

3

これを試して

select
  group_concat(t.week_no) as Weeks,
  group_concat(t.death_count) as DeathCounts
from (SELECT
    WEEK(cpd.added_date) AS week_no,
    COUNT(cpd.result) AS death_count
      FROM cron_players_data cpd
      WHERE cpd.player_id = 81
      AND cpd.result = 2
      AND cpd.status = 1
      GROUP BY WEEK(cpd.added_date)) as t
于 2012-06-27T15:04:21.627 に答える
1

この代替ソリューション はどうですか?

クエリ

select group_concat( week_no ) as week_no, group_concat( death_count ) as death_count
from (
    SELECT WEEK(cpd.added_date) AS week_no,COUNT(cpd.result) AS death_count
    FROM cron_players_data cpd WHERE cpd.player_id = 81
    AND cpd.result = 2 AND cpd.status = 1
    GROUP BY WEEK(cpd.added_date)
) grouped_data
;
于 2012-06-27T15:05:46.800 に答える