我有以下查询来计算总和时间戳
SELECT SUM(TIME_SPENT) FROM
(
select a - b as time_spent from tbl1 where name = 'xxx'
union all
select c - d as time_spent from tbl2 where name= 'yyy'
)a;
子查询返回结果为 +00 00:01:54.252000 但整个查询返回错误为 ORA-00932:不一致的数据类型:预期 NUMBER 得到 INTERVAL DAY TO SECOND。
理解它需要这样的东西
SELECT COALESCE (
(to_timestamp('2014-09-22 16:00:00','yyyy/mm/dd HH24:MI:SS') - to_timestamp('2014-09-22 09:00:00','yyyy/mm/dd HH24:MI:SS')) -
(to_timestamp('2014-09-22 16:00:00','yyyy/mm/dd HH24:MI:SS') - to_timestamp('2014-09-22 09:00:00','yyyy/mm/dd HH24:MI:SS')), INTERVAL '0' DAY) FROM DUAL;
如何与从 Timestamp 类型列中检索数据的子查询一起实现?