如何获得以秒为单位的Bigquery中记录的平均间隔

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

我正在尝试使用standardSql获取BigQuery中记录的平均间隔。我看了一些示例,但无法使其正常工作。

select timestamp_diff(timestamp, MIN(timestamp), MAX(timestamp)) / (COUNT(DISTINCT(timestamp), SECOND) 
from `data-analysis.customer_analytics._aoi_table`
where flight_number = 'JL540' AND icao_address = '851958'
order by timestamp

下面是我的表格图像,我想获取列时间戳记中记录之间的平均间隔。

enter image description here

google-bigquery average intervals
1个回答
1
投票

此方法:

select 
timestamp_diff(max(timestamp),
min(timestamp),SECOND) / (COUNT(DISTINCT(timestamp)) - 1) 
from `ais-data-analysis.customer_analytics.itochu_aoi_table`
where flight_number = 'JL540' 
AND icao_address = '851958'
© www.soinside.com 2019 - 2024. All rights reserved.