0
我有以下查詢,它會生成一個表。使用GROUP BY分組到兩列
SELECT c.name AS campaign
, c.traffic_source
, ic.keyword
, COUNT(ic.keyword) AS keycount
, SUM(ls.amount) AS total_amount
, ls.buyer AS buyers
, ic.create_date AS 'date'
FROM in_clicks AS ic
INNER JOIN ads AS a ON (ic.ad_id = a.id)
INNER JOIN ad_groups AS ag ON (a.ad_group_id = ag.id)
INNER JOIN campaigns AS c ON (ag.campaign_id = c.id)
INNER JOIN leads AS l ON (ic.id = l.in_click_id)
INNER JOIN lead_status AS ls ON (l.id = ls.lead_id)
WHERE keyword IS NOT NULL AND ic.create_date BETWEEN '2011-08-21' AND '2011-08-22'
AND ic.location NOT LIKE 'Littleton%' AND ls.discriminator = 'AUTO_POST'
GROUP BY ic.keyword
ORDER BY keycount DESC
,該查詢產生(略):
campaign count
Auto 10
Auto Branded 8
Auto California 7
Auto Branded 6
Auto 2
Auto 2
Auto California 1
我想要做的是根據雙方的「計數」和活動名稱的數據組。 因此,它看起來像:
campaign count
Auto 10
Auto 2
Auto 2
Auto Branded 8
Auto Branded 6
Auto California 7
Auto California 1
我怎樣才能獲得小組活動和統計在一起?
謝謝...運動不應該有DESC,但除此之外,該訣竅 – ATMathew
有趣的是,我貼我的回答你做1個min13s之前。 :) –
嗯,我認爲這就像我們最初發布時間相距幾秒鐘......但我已upvoted你的答案,如果這是任何安慰:) – ain