I am facing a problem in formatting the output of a query:
SELECT i.product AS "Product Line",
COUNT(i.incident_id) "Count Of Tickets",
TRUNC((SUM(NVL(RSSEC,0) - NVL(WCTSEC,0))/COUNT(i.incident_id)) / 86400)
|| ':'
|| TRUNC(MOD(((SUM(NVL(RSSEC,0) - NVL(WCTSEC,0))/COUNT(i.incident_id)) / 3600),24))
|| ':'
|| TRUNC(MOD(((SUM(NVL(RSSEC,0) - NVL(WCTSEC,0))/COUNT(i.incident_id)) / 60),60))
|| ':'
|| TRUNC(MOD((SUM( NVL(RSSEC,0) - NVL(WCTSEC,0))/COUNT(i.incident_id)),60)) AS "MTTR"
FROM info i;
where RSSEC-Total RSeconds(type number)
WCTSEC- Total WSeconds(type number)
Current Output: TTPLL 8 2:4:0:18 ASDASDADD 1 0:0:9:0 UASDF 2 0:0:0:8 ERTEU 4 0:3:0:46
Expected Output: TTPLL 8 02:04:00:18 ASDASDADD 1 00:00:09:00 UASDF 2 00:00:00:08 ERTEU 4 00:03:00:46
Can anyone help me out to achieve the above format?
Please let me know for any alternative solution to get above output format other than truncate position.
Thanks in advance,
I don't know which RDBMS this is, so I'm guessing, but how about this one?
SELECT i.product AS "Product Line",
COUNT(i.incident_id) "Count Of Tickets",
RIGHT('0' || TRUNC((SUM(NVL(RSSEC,0) - NVL(WCTSEC,0))/COUNT(i.incident_id)) / 86400), 2)
|| ':'
|| RIGHT('0' || TRUNC(MOD(((SUM(NVL(RSSEC,0) - NVL(WCTSEC,0))/COUNT(i.incident_id)) / 3600),24)), 2)
|| ':'
|| RIGHT('0' || TRUNC(MOD(((SUM(NVL(RSSEC,0) - NVL(WCTSEC,0))/COUNT(i.incident_id)) / 60),60)), 2)
|| ':'
|| RIGHT('0' || TRUNC(MOD((SUM( NVL(RSSEC,0) - NVL(WCTSEC,0))/COUNT(i.incident_id)),60)), 2) AS "MTTR"
FROM info i;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.