gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 09:15:07 25 4
gpt4 key购买 nike

我想排除计数以删除以下查询中的重复项

SELECT *, count(1) as count except (count)
FROM PRD.sites
group by site,id ,site_desc,timestamp
having count(1) < 2

但在 [1:29] 出现错误 Unexpected keyword EXCEPT。我正在使用标准 SQL

最佳答案

你可以试试下面

select * except(count)
from
(
SELECT *, count(1) as count
FROM PRD.sites
group by site,id ,site_desc,timestamp
having count(1) < 2
)X

或者您可以使用 row_number() 查找重复项

SELECT * except(rn)
FROM (
SELECT
*,
ROW_NUMBER()
OVER (PARTITION BY site,id ,site_desc,timestamp) as rn
FROM FROM PRD.sites
)
WHERE rn= 1

关于sql - 选择 bigquery 中除一列以外的所有列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53001825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com