我希望按照某些标准对自定义营销渠道进行编码,如下所示:
SELECT
date,
trafficSource.medium,
case
when trafficSource.medium like '%cpc%' then 'Paid Search'
end as channel
FROM `xyz.ga_sessions_2017*`
limit 1000
这给了我
的结果date | medium | channel
--------------------------------------
20171212 | cpc | Paid Search
我也可以将我的关键绩效指标看作是这样
SELECT
date,
SUM(totals.visits) visits,
SUM(totals.pageviews) pageviews,
SUM(totals.transactions) transactions,
SUM(totals.transactionRevenue)/1000000 revenue
FROM `xyz.ga_sessions_2017*`
GROUP BY
date
ORDER BY
date ASC
给了我这个结果
date | visits | pageviews | transactions | revenue
--------------------------------------------------------------------
20171212 | 1234 | 5678 | 1111 | 99999
然而,我的目标是将这两者组合在一起,这应该是:
date | medium | channel | visits | pageviews | transactions | revenue
-----------------------------------------------------------------------------------------
20171211 | cpc | Paid Search | 18 | 50 | 17 | 2578
20171212 | cpc | Paid Search | 27 | 90 | 35 | 2981
任何提示或建议?
答案 0 :(得分:1)
以下是BigQuery Standard SQL
Response.Listener<JSONArray>