sql - 如何轻松列出 BigQuery 中的列
问题描述
我在 BigQuery 中有一个包含许多列的表。我想在选择查询中列出它的列,但列出所有列很难。
我想做这样
SELECT
col1,
col2,
col3,
...
SOME_METHOD(col30),
...
col50
FROM
foo.bar;
有什么方法可以轻松编写这样的查询吗?
解决方案
以下是 BigQuery 标准 SQL
SELECT * EXCEPT(col30), SOME_METHOD(col30)
FROM foo.bar
或者
SELECT * REPLACE(SOME_METHOD(col30) as col30)
FROM foo.bar
例如
#standardSQL
WITH `project.dataset.table` AS (
SELECT 1 col1, 2 col2, 3 col3, 4 col4, 5 col5
)
SELECT * EXCEPT(col3), 2 * col3 AS col3
FROM `project.dataset.table`
结果
Row col1 col2 col4 col5 col3
1 1 2 4 5 6
或者
#standardSQL
WITH `project.dataset.table` AS (
SELECT 1 col1, 2 col2, 3 col3, 4 col4, 5 col5
)
SELECT * REPLACE(2 * col3 AS col3)
FROM `project.dataset.table`
结果
Row col1 col2 col3 col4 col5
1 1 2 6 4 5
推荐阅读
- python - python - 如何提取 DOCX 超链接的文本?
- logstash - logstash 自定义模式没有得到解决
- java - 通过 Firebase ML Kit 人脸检测检测多张人脸的轮廓
- c# - Xamarin 表单的 EF Core 与 Web API 的性能
- vba - 无法获取活动幻灯片的索引
- sql - 如何编写 SQL 来选择具有每个组的最大值(值)的行?
- sql-server - 我该如何解决这个 SISS 问题?
- jquery - 仅在课程“活动”时添加
- android - 如何防止应用在 Glide onResourceReady 上崩溃
- 3d - 使用由moodle书内的滑块(jquery ui)动画的卷轴js对象。它不起作用