/* ************************************************ *
* 일별 통계 구하기 : 2017-07-01 ~ 2017-07-31
* ************************************************ */
WITH CTE_MONTHS AS (SELECT '2017-07-01' AS THIS_DATE
UNION ALL
SELECT CONVERT(VARCHAR(10), DATEADD(DAY, 1, THIS_DATE), 120) AS THIS_DATE
FROM CTE_MONTHS
WHERE (CONVERT(VARCHAR(10), DATEADD(DAY, 1, THIS_DATE), 120) <= '2017-07-31')
)
SELECT A.THIS_DATE, ISNULL(B.TOTAL_COUNT, 0) AS NEW
FROM CTE_MONTHS AS A LEFT OUTER JOIN
(SELECT CONVERT(VARCHAR(10), get_date_column, 121) AS REGIST_DATE, COUNT(*) AS TOTAL_COUNT
FROM [TABLE]
WHERE (get_date_column BETWEEN '2017-07-01' AND DATEADD(DAY, 1, '2017-07-31'))
GROUP BY CONVERT(VARCHAR(10), get_date_column, 121)) AS B
ON A.THIS_DATE = B.REGIST_DATE
ORDER BY A.THIS_DATE