在Bigquery中对记录进行分组并获取标准偏差间隔

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

我下面有一个SQL,它能够获取按icao_address,flight_number,flight_date分组的timestamp列的间隔平均值。我实际上不确定如何在另一列中获取与上述相同分组的记录间隔的标准差。

下面是我的SQL

#standardSQL
select DATE(timestamp) as flight_date, safe_divide(timestamp_diff(max(timestamp), min(timestamp),SECOND), (COUNT(DISTINCT(timestamp)) - 1)) as avg_interval_message, icao_address, flight_number, min(timestamp) as firstrecord, max(timestamp) as lastrecord
from `customer_analytics._aoi_table`
group by icao_address, flight_number, flight_date
having avg_interval_message is not null and flight_number is not null
order by flight_date, avg_interval_message ASC

同样,我只需要添加与avg_interval_message类似的另一列的指导,但要取平均值,它将具有标准偏差。

enter image description here

group-by google-bigquery intervals standard-deviation
1个回答
0
投票

您可以使用STDDEV_POP(<FLOAT>)计算标准偏差,如您所见here

希望对您有帮助

© www.soinside.com 2019 - 2024. All rights reserved.