3,490
社区成员
发帖
与我相关
我的任务
分享
select faulttype, sum(endtime - starttime) * 24 * 60 ttltime
from (select faulttype,
starttime,
nvl(endtime,
to_date('2009-02-15 12:00:00', 'yyyy-mm-dd hh24:mi:ss')) endtime
from tablename)
where starttime >= to_date('2008-05-12 10:00:00', 'yyyy-mm-dd hh24:mi:ss')
and starttime <= to_date('2009-02-15 12:00:00', 'yyyy-mm-dd hh24:mi:ss')
and endtime >= to_date('2008-05-12 10:00:00', 'yyyy-mm-dd hh24:mi:ss')
and endtime <= to_date('2009-02-15 12:00:00', 'yyyy-mm-dd hh24:mi:ss')
group by faulttype
select faulttype, sum(endtime - starttime) * 24 * 60 ttltime
from (select faulttype,
starttime,
nvl(endtime,
to_date('2009-02-15 12:00:00', 'yyyy-mm-dd hh24:mi:ss')) endtime
from tablename)
where starttime <= to_date('2009-02-15 12:00:00', 'yyyy-mm-dd hh24:mi:ss')
and endtime >= to_date('2008-05-12 10:00:00', 'yyyy-mm-dd hh24:mi:ss')
group by faulttype