我使用此查询来显示代理名称resolved_by
和他/她解析的服务计数,此外,我还想显示每个代理解析的所有服务从报告服务creation_Date
到解析服务last_resolved_date
之间所花费的时间总和,并且我想以天、小时和分钟显示该时间,我该怎么做呢?下面的查询给出了奇怪的结果
select resolved_by,
count(resolved_by) services_resolved,
round(sum((last_resolved_date+0)-(creation_date+0)),0) || 'Days' ||
round(sum(((last_resolved_date+0)-(creation_date+0))*24),0) || 'Hours' ||
round(sum(((last_resolved_date+0)-(creation_date+0))*24*60),0) || 'Minutes' effort
from svc_service_requests
where status_type_cd = 'ORA_SVC_RESOLVED'
group by resolved_by
例如:14 Days 327 Hours 19598 Minutes
2条答案
按热度按时间dohp0rv51#
下面是一个通用函数,它接受日期或时间戳,并返回两者的差值
7ajki6be2#
使用
MOD
获取小时/分钟和TRUNC
(或FLOOR
):如果列是
TIMESTAMP
s,则可以使用CAST(last_resolved_date AS DATE)
和CAST(creation_date AS DATE)
。