我试图找出我的下面的查询有什么问题,当我运行它时,它似乎要求我将一个组添加到不在我的声明中的记录。
SELECT date,
SUM(totals.visits) as visits,
SUM(totals.transactions) as Transactions,
SUM( totals.transactionRevenue) as Revenue,
SUM (hits.eCommerceAction.action_type ='3'),
Sites
FROM
(SELECT *, "SiteA" as Sites
FROM (TABLE_DATE_RANGE([mydata.ga_sessions_],DATE_ADD(CURRENT_TIMESTAMP(), -6, 'DAY'), DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY'))),
(TABLE_DATE_RANGE([mydata.ga_sessions_intraday_], DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY'), CURRENT_TIMESTAMP()))
GROUP BY
date
ORDER BY
date DESC);
请告诉我 感谢
答案 0 :(得分:1)
我认为您错误地将您的小组定位并按顺序排列 假设其余代码有意义 - 下面应该有效
SELECT
date,
SUM(totals.visits) AS visits,
SUM(totals.transactions) AS Transactions,
SUM( totals.transactionRevenue) AS Revenue,
SUM (hits.eCommerceAction.action_type ='3'),
Sites
FROM (
SELECT *, "SiteA" AS Sites
FROM
(TABLE_DATE_RANGE([mydata.ga_sessions_],DATE_ADD(CURRENT_TIMESTAMP(), -6, 'DAY'), DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY'))),
(TABLE_DATE_RANGE([mydata.ga_sessions_intraday_], DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY'), CURRENT_TIMESTAMP()))
)
GROUP BY date, Sites
ORDER BY date DESC