我没有得到正确的结果,我尝试了下面的查询,并得到了一些奇怪的小数
CREATE TABLE "EXAMPLE"
("LOCATION_I" NUMBER NOT NULL ENABLE,
"START_TS" DATE,
"END_TS" DATE,
CONSTRAINT "TABLE1_PK" PRIMARY KEY ("LOCATION_I")
) ;
Insert into EXAMPLE (LOCATION_I,START_TS,END_TS) values (1,to_date('14-11-17','DD-MM-RR'),to_date('15-11-17','DD-MM-RR'));
Insert into EXAMPLE (LOCATION_I,START_TS,END_TS) values (2,to_date('13-11-17','DD-MM-RR'),to_date('14-11-17','DD-MM-RR'));
Insert into EXAMPLE (LOCATION_I,START_TS,END_TS) values (3,to_date('12-11-17','DD-MM-RR'),to_date('13-11-17','DD-MM-RR'));
select LOCATION_I, avg(END_TS - START_TS) from EXAMPLE where END_TS is not null GROUP BY LOCATION_I;
请建议解决方案..
这是更大的sql的一部分。 .................................................. .................................................. .................................................. .................................................. .................................................. ...........