Sums for Last MTD and YTD produce multiple rows
Hi,
I am trying to obtain sums for Last 24 hrs, MTD and YTD using the following SQL. The Last 24hrs produces a single row which is what I would expect. However, when I add in the MTD and YTD I receive multiple rows. I imagine I have a simple error in my code. Any ideas?
select (select sum(TOTAL_MINS_OUTAGE) from INCIDENTS
where SERVICE_CUSTOMER_FINANCIAL_SERVICE_SUBCAT_CIM='On'
and OPEN_DATE>= date(now()) - interval 1 Day) as Last_24,
(select distinct sum(TOTAL_MINS_OUTAGE) from INCIDENTS where
SERVICE_CUSTOMER_FINANCIAL_SERVICE_SUBCAT_CIM='On' and
year(curdate()) =year(OPEN_DATE) and month(curdate()) = month(OPEN_DATE)) as MTD,
(select sum(TOTAL_MINS_OUTAGE) from INCIDENTS where
SERVICE_CUSTOMER_FINANCIAL_SERVICE_SUBCAT_CIM='On' and
year(curdate()) =year(OPEN_DATE)) as YTD
from INCIDENTS;
Subject
Written By
Posted
Sums for Last MTD and YTD produce multiple rows
December 07, 2016 03:18PM
December 07, 2016 05:22PM
December 09, 2016 07:13PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.