Google bigquery google bigquery上时间列的SUM()
我有这张桌子: TripDrivingDuration列是字符串类型的列,我尝试将字符串转换为time,然后求和,但不起作用Google bigquery google bigquery上时间列的SUM(),google-bigquery,Google Bigquery,我有这张桌子: TripDrivingDuration列是字符串类型的列,我尝试将字符串转换为time,然后求和,但不起作用 有人能帮我吗?这对你有用吗 WITH DATA as( select 29 as VehicleId, '2017-01-02T 15:57:063000' as TripDateTime, '00:00:28' as TripDrivingDuration union all select 29 as VehicleId, '2017-01-02T 13:23:12
有人能帮我吗?这对你有用吗
WITH DATA as(
select 29 as VehicleId, '2017-01-02T 15:57:063000' as TripDateTime, '00:00:28' as TripDrivingDuration union all
select 29 as VehicleId, '2017-01-02T 13:23:12' as TripDateTime, '00:00:21' as TripDrivingDuration union all
select 29 as VehicleId, '2017-01-02T 17:23:05.063000' as TripDateTime, '00:07:11.9370000' as TripDrivingDuration union all
select 29 as VehicleId, '2017-01-02T 14:59:44.063000' as TripDateTime, '00:08:19.9370000' as TripDrivingDuration union all
select 29 as VehicleId, '2017-01-02T 15:45:44.063000' as TripDateTime, '00:01:22.9370000' as TripDrivingDuration union all
select 29 as VehicleId, '2017-01-02T 15:17:58.063000' as TripDateTime, '00:03:29.9370000' as TripDrivingDuration union all
select 29 as VehicleId, '2017-01-02T 18:52:15' as TripDateTime, '00:01:26' as TripDrivingDuration union all
select 29 as VehicleId, '2017-01-02T 17:05:24.063000' as TripDateTime, '00:13:09.9370000' as TripDrivingDuration
)
SELECT
VehicleId,
SUM(UNIX_SECONDS(PARSE_TIMESTAMP('%H:%M:%S', REGEXP_EXTRACT(TripDrivingDuration, r'(.*)\.\d+')))) elapsed_time
FROM data
GROUP BY VehicleId
你期望结果是什么?对时间戳求和是没有意义的。嗨,Elliott,这个列表示一次旅行的持续时间,所以我想得到按日期分组的Every deviceId的总持续时间。谢谢,这对我有很大帮助。这就是答案