我的查询:
SELECT AVG(time_out - time_in) from time_table
结果:
3 days 17:21:21.062313
问题是,计算的平均值也有一秒的小数部分.062313,我不需要,所以我必须放弃它。我该怎么做?
答案 0 :(得分:3)
date_trunc
应该这样做:
SELECT date_trunc('second', avg(time_out - time_in)) FROM time_table
答案 1 :(得分:1)
SELECT (AVG(time_out - time_in))::INTERVAL(0) FROM time_table;
或
SELECT CAST(AVG(time_out - time_in) AS INTERVAL(0)) FROM time_table;