In my table, I'm storing action_seconds
for any event in seconds
Table Name: event_table
id | action_seconds
1 | 90
2 | 120
3 | 140
Now, when I calculate avg of action_seconds,
Query: select avg(action_seconds) from event_table;
Expected Output: 1.56
Actual Output: 116.66
Is it possible? how to do? what kind of casting I have to implement to achieve this expected result?
答案 0 :(得分:1)
使用以下查询。这将返回平均值(最初为秒),为minutes.seconds
SELECT TO_CHAR((AVG(action_seconds) || ' second')::interval, 'MI.SS') FROM event_table;