有没有办法从间隔中删除年、月、日?

Is there a way for me to remove the Year,Month,Day from an interval?

我希望这个 0-0 0 502:9:14 是这个 502:9:14。

SELECT
    ride_id,
    started_at, --timestamp
    ended_at, -- timestamp
    ended_at - started_at AS ride_length, --interval
FROM `project-id.bike_share.202102`
ORDER BY ride_length DESC

您可能想考虑使用 justify_interval:

规范化间隔
SELECT
    ride_id,
    started_at, --timestamp
    ended_at, -- timestamp
    justify_interval(ended_at - started_at) AS ride_length --interval
FROM `project-id.bike_share.202102`
ORDER BY ride_length DESC

输出样本:

Row     justified_ride_length    ride_length    
1       0-0 20 22:19:14          0-0 0 502:19:14

否则,我认为你必须使用 extract :
select concat(extract(hour from i),':',extract(minute from i),':',extract(second from i)) ride_length_2
FROM `project-id.bike_share.202102` t
left join unnest ([t.ended_at - t.started_at]) as i

输出样本:

Row     ride_length        ride_length_2    
1       0-0 0 502:19:14    502:19:14

I want this 0-0 0 502:9:14 to be this 502:9:14

试试下面的简单方法

SELECT
  ride_id,
  started_at, 
  ended_at, 
  ended_at - started_at AS ride_length, 
  replace('' || (ended_at - started_at), '0-0 0 ', '') AS ride_length_as_hhmmss, 
FROM `project-id.bike_share.202102`

下面是输出示例