如何在单列上使用非重复并在bigquery中返回多个其他列?

问题描述 投票:0回答:1

我有一个BigQuery表,该表具有重复的值,我想使用不同的运算符删除这些重复项。但执行以下查询后未获得预期的输出。

这里是查询:

SELECT DISTINCT
    customerRefNo,
    custType,
    executionDate,
    Unit
FROM `myproject.mydataset.mytable`

在我的表格中有customerRefNo的重复项,并希望将其删除。任何人的任何建议?

google-cloud-platform google-bigquery distinct-values
1个回答
0
投票

根据您的评论,以下GROUP BY查询可能与您想要的类似:

SELECT
    customerRefNo,
    custType,
    MAX(executionDate) AS executionDate,
    Unit
FROM `myproject.mydataset.mytable`
GROUP BY
    customerRefNo,
    custType,
    Unit;
© www.soinside.com 2019 - 2024. All rights reserved.