google-bigquery - 如何在BigQuery Standard SQL中生成序列

标签 google-bigquery

我需要生成每行包含600个连续数字(以51开头)的表
如何使用BigQuery标准SQL?

最佳答案

在标准SQL中尝试GENERATE_ARRAY

SELECT num FROM UNNEST(GENERATE_ARRAY(51, 650)) AS num;


编辑:如果您想要超过一百万个元素,则可以使用多次调用GENERATE_ARRAY,尽管会警告您,如果生成太多元素,查询可能会花费很长时间:

SELECT num1 * num2 AS num
FROM UNNEST(GENERATE_ARRAY(1, 1000000)) AS num1,
  UNNEST(GENERATE_ARRAY(1, 100)) AS num2;

关于google-bigquery - 如何在BigQuery Standard SQL中生成序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38884708/

相关文章:

mysql - BigQuery 语法错误

python - 如何从 Airflow 中的 Big Query 获取 SQL 查询的结果?

firebase - Google Firebase事件原始数据中关键 "previous_timestamp_micros"的含义是什么

sql - BigQuery中的WITH

sql - 选择 bigquery 中除一列以外的所有列

sql - 了解 "Not found: Dataset ### was not found in location US"错误

google-cloud-platform - Google Play转移频率错误-Google BigQuery

google-bigquery - 如何在BigQuery Standard SQL中将时间戳转换为秒

json - 将 BigQuery 表导出到 GCS 作为 CSV 或 JSON 生成文件类型文件

sql - bigquery 中最近 30 天的结果