【发布时间】:2021-03-08 12:25:02
【问题描述】:
我在 BigQuery 中有一个 SQL 查询:
SELECT
creator.country,
(SUM(length) / 60) AS total_minutes,
COUNT(DISTINCT creator.id) AS total_users,
(SUM(length) / 60 / COUNT(DISTINCT creator.id)) AS minutes_per_user
FROM
...
您可能已经注意到最后一列等同于total_minutes / total_users。
我试过了,但它不起作用:
SELECT
creator.country,
(SUM(length) / 60) AS total_minutes,
COUNT(DISTINCT creator.id) AS total_users,
(total_minutes / total_users) AS minutes_per_user
FROM
...
有什么方法可以让这更简单吗?
【问题讨论】:
标签: sql google-bigquery