Oracle查询每日新增用户数量

SELECT
NVL(A.dateDay,duleTable.days) dateTimes ,NVL(a.addnum, 0) newNum
FROM
(
SELECT
TO_CHAR (
SYSDATE - ROWNUM + 1,
'YYYY-MM-dd'
) AS days
FROM
dual CONNECT BY ROWNUM < 60
) duleTable
LEFT JOIN (
SELECT
COUNT (1) addNum,
TO_CHAR (
baseUser.CREATE_TIME,
'YYYY-MM-DD'
) dateDay
FROM
BASE_USER baseUser
WHERE
baseUser.STATUS = 0
GROUP BY
TO_CHAR (
baseUser.CREATE_TIME,
'YYYY-MM-DD'
)
) A ON duleTable.days = A .dateDay
ORDER BY
duleTable.days DESC

你可能感兴趣的:(数据筛选)