答案 0 :(得分:3)
在SELECT
之前,您还缺少一个结束括号
应该是
WITH allTables AS (
SELECT
UNIX_SECONDS(TIMESTAMP(DATE)) AS DATE,
SUM(CASE WHEN period = 7 THEN users END) AS days_07
FROM (
SELECT
activity.date AS DATE,
periods.period AS period,
COUNT(DISTINCT user) AS users
FROM (
SELECT
activity.date AS DATE,
periods.period AS period,
COUNT(DISTINCT user) AS users
FROM (
SELECT
DISTINCT DATE(TIMESTAMP_MICROS(event.timestamp_micros)) AS DATE,
user_dim.app_info.app_instance_id AS user
FROM `hidden.*`
CROSS JOIN
UNNEST(event_dim) AS event
) AS activity
CROSS JOIN (
SELECT
DATE(TIMESTAMP_MICROS(event.timestamp_micros)) AS DATE
FROM `hidden.*`
CROSS JOIN
UNNEST(event_dim) AS event
GROUP BY event.timestamp_micros
) AS dates
CROSS JOIN (
SELECT period FROM (SELECT 7 AS period)
) AS periods
WHERE
dates.date >= activity.date
AND
SAFE_CAST(FLOOR(DATE_DIFF(dates.date, activity.date, DAY)/periods.period) AS INT64) = 0
GROUP BY 1,2
) GROUP BY DATE ORDER BY DATE
)
) SELECT 'all apps' AS target, DATE AS datapoint_time, days_07 AS datapoint_value FROM allTables
希望分享处理此类问题的超级简单方法"
1.将疑问查询复制到查询编辑器
2.确保选择正确的SQL版本(可选但最好完成它)
3.现在您可以使用代码折叠功能。您可以折叠(折叠)代码片段,将它们缩小为单个可见行。通过这种方式,您可以隐藏目前看起来不重要的细节。如果需要,可以扩展(展开)折叠的代码片段。折叠时 - 您可以观察您的代码,将实现细节放在一边,并专注于结构等。此外,它还有助于识别您的案例中的错误
4.然后你可以使用编辑器的括号匹配功能(如下)
清楚地看到匹配的支架丢失了