postgresql - 在 BigQuery(或 Postgres)中定义常量表

标签 postgresql google-bigquery

如何在 BigQuery 中用简单的单行定义临时常量表(或 Postgres,其语法可能适用于 BigQuery)?

with my_fruits as (
--- ??? define a table 
--- consisting of a single column fruit_name
--- with values ('apple', 'pear', 'gooseberry', ...  (12 more fruits))
)
select * from my_fruits left join 
(select fruit_name, 1 is_present from my_dataset.your_fruits)
using (fruit_name)

最佳答案

您可以使用UNNEST :

select * from unnest(['apple', 'pear', 'gooseberry']) as fruit_name

您还可以加入 UNNEST directly .

关于postgresql - 在 BigQuery(或 Postgres)中定义常量表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65103868/

相关文章:

sql - 在 BigQuery 中优化查询

google-bigquery - BigQuery - 将 ""设置为 Null

python - 时间未添加到 Python 中的日期对象

PostgreSQL:有效地将数据加载到星型模式中

sql - postgres 从间接相关的表中删除

r - 查询表并生成国家代码分组和绘图条形图的代码

google-bigquery - 在窗口中过滤分区 - 在 BigQuery 中计算事件新近度

ruby-on-rails - Postgres 无法连接到 Unix 域套接字 5432 上的服务器

google-bigquery - BigQuery 中的自联接问题

pyspark - 如何在 GCS 中的增量表之上创建 BQ 外部表并仅显示最新快照