日期:2014-05-17 浏览次数:21338 次
SELECT T1.DDATE, T2.SS, T2.CC
FROM (SELECT TO_CHAR(SDATE + (ROWNUM - 1), 'yyyy-mm-dd') DDATE
FROM (SELECT TO_DATE('2014-04-01', 'yyyy-mm-dd') SDATE,
TO_DATE('2014-04-30', 'yyyy-mm-dd') EDATE
FROM DUAL) T
CONNECT BY SDATE + (ROWNUM - 1) <= EDATE) T1,
(SELECT TO_CHAR(SERVICE_OPENTIME, 'yyyy-mm-dd') SDATE,
SUM(1) SS,
COUNT(1) CC
FROM T_AGENT_SERVICE_MSISDN
WHERE TO_CHAR = (SERVICE_OPENTIME, 'yyyy-mm') = '2014-04'
GROUP BY SERVICE_OPENTIME) T2
WHERE T1.DDATE = T2.SDATE(+)
SELECT TO_CHAR(SERVICE_OPENTIME, 'yyyy-mm-dd') SDATE,
SUM(1) SS,
COUNT(1) CC
FROM T_AGENT_SERVICE_MSISDN
WHERE TO_CHAR = (SERVICE_OPENTIME, 'yyyy-mm') = '2014-04'
GROUP BY SERVICE_OPENTIME