BigQuery 获取唯一行 [英] BigQuery get unique rows
本文介绍了BigQuery 获取唯一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这些行,我想知道如何只获取按 id、unit_number、序列号和驱动程序分组的唯一行,但同时获取该行的日期
I have this rows, i would like to know how to only get the unique rows grouped by id, unit_number, serial number and driver, but at the same time get the date of that row
SELECT
id,
date
FROM
`table`
GROUP BY
id,
date
ORDER BY
id, date DESC
推荐答案
您可以使用聚合函数:
SELECT id, unit_number, MAX(date)
FROM `table`
GROUP BY id, unit_number
ORDER BY id, MAX(date) DESC
这篇关于BigQuery 获取唯一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文