Reputation: 1174
I need a time in minutes and seconds. If minutes is greater than 60 I then add to minutes, but do not convert hours
Query :
TO_CHAR((sum(seconds)|| ' second')::interval,'HH24:MI:SS')
as duration from table;
Output:
DURATION
02:50:21
Required Output:
DURATION
170:21
even i have tried another query (without HH24) but i get below out put:
Query :
TO_CHAR((sum(seconds)|| ' second')::interval,'MI:SS') as duration from table;
Output:
DURATION
50:21
Here we can see from 1st query output 02 hrs means 120 minutes + 50minutes =170 minutes and seconds same as it is.
is it possible directly getting from query or not?
Upvotes: 0
Views: 1009
Reputation: 19257
you don't need to_char
here:
select (sum(seconds) / 60)::text || ':' || (sum(seconds) % 60) ...;
Upvotes: 3