我遇到了一個MySQL查詢的麻煩,我想選擇SUM,否則如果語句,這是我的故事。MySQL的查詢將SUM,但如果在其他領域的語句
我的查詢:
SELECT SUM(s.total_revenue) AS sum_revenue, m.revenue_type AS revenue_type, d.campaignid AS placement_id
FROM ox_data_summary_ad_hourly AS s
INNER JOIN ox_banners AS d ON (d.bannerid = s.ad_id)
INNER JOIN ox_campaigns AS m ON (m.campaignid = d.campaignid)
INNER JOIN ox_clients AS a ON (a.clientid = m.clientid)
WHERE a.type = 0
GROUP BY placement_id
LIMIT 0 , 30
而在上面的查詢得到的結果如下:
我要生成查詢,其中: 如果revenue_type = 4將值改爲sum_revenue =值placement_id, 示例結果我想要如下圖所示:
謝謝你的幫助。
好的,謝謝。解決了。 – 2013-03-20 19:47:39
@LorenRamly很高興你得到它的工作 – Taryn 2013-03-20 19:48:04
好吧感謝兄弟,我在玩openx :) – 2013-03-20 19:56:34