在postgresql中将interval转换为number

时间:2017-07-31 13:18:54

标签: postgresql types type-conversion

我创建了一个查询,它总结了各个日期时间的间隔

select sum(ts_polling) / count(ts_polling) as Average_Queue_Wait_Time ,  cast(time_start AS Date)
  from callcent_queuecalls group by cast(time_start AS date) order by time_start DESC;

enter image description here

有没有办法将Average_Queue_Wait_Time从间隔数据类型转换为数字?

1 个答案:

答案 0 :(得分:1)

你可以在这样的时间间隔内获得秒数:

SELECT EXTRACT(epoch FROM INTERVAL '1 day 30 minutes 1.234 seconds');

┌───────────┐
│ date_part │
├───────────┤
│ 88201.234 │
└───────────┘
(1 row)