我的查询很简单,但花了很长时间。我是 BigQuery Studio 的新手,但我怀疑我已导入 BigQuery 的电子表格。 这是查询:
WITH MaxStepsPerDay AS (
SELECT
Date,
MAX(Steps) AS Max_Steps
FROM `soy-codex-441615-u9.Women_wellness.minutes_Steps_March_to_april`
WHERE Id = 1503960366
GROUP BY Date
)
SELECT
ms.Date,
ms.Max_Steps,
original.Time
FROM MaxStepsPerDay ms
JOIN `soy-codex-441615-u9.Women_wellness.minutes_Steps_March_to_april` original
ON ms.Date = original.Date AND ms.Max_Steps = original.Steps
WHERE original.Id = 1503960366;
错误信息是这样的:
查询执行期间超出资源:电子表格 ID 的 Google 表格服务超载:1J2zfUFbAWPtouinGNXbFZ_lmDvIT3k_gwGRsllRbQS0
如果有人能帮助我,我会很高兴, 谢谢!
在 BQ 临时表中提取数据,然后按如下方式应用联接。这将降低复杂性
BEGIN
CREATE TEMP TABLE MaxStepsPerDay AS (
SELECT Date,
MAX(Steps) AS Max_Steps
FROM `soy-codex-441615-u9.Women_wellness.minutes_Steps_March_to_april`
WHERE Id = 1503960366
GROUP BY Date
);
CREATE TEMP TABLE minutes_Steps_March_to_april AS (
SELECT DATE,
Steps,
Time,
FROM `soy-codex-441615-u9.Women_wellness.minutes_Steps_March_to_april`
WHERE Id = 1503960366
);
SELECT
ms.Date,
ms.Max_Steps,
original.Time
FROM MaxStepsPerDay ms
JOIN minutes_Steps_March_to_april original
ON ms.Date = original.Date AND ms.Max_Steps = original.Steps;
END;