Averaging time field

Analytics
N/A

Averaging time field

Hello there,

I am encountering an error when I am trying to perform average function on a field with data type of time(0).

For example:

sel avg(end_time)
from table1

It gave error "5407: Invalid operation on an ANSI Datatime or Interval value"

I tried:

sel sum(end_time)/count(end_time)
from table1

This failed with the same error message due to the sum function.

Has anyone encountered this problem before? If so, can someone be kindly offer a solution to this?

Thanks in advanced,
N
1 REPLY
N/A

Re: Averaging time field

Hi
I tried following and i am getting the result.

create table time_test
(
t1 time
)primary index(t1);

insert into d_temp_hutch.time_test('12:00');
insert into d_temp_hutch.time_test('14:00');
insert into d_temp_hutch.time_test('18:00');

sel avg(t1)
from d_temp_hutch.time_test;

Average(t1)
00:14:66