SELECT A.FDATE, COUNT(B.STARTDATE) FNUM
FROM (SELECT FDATE
FROM (SELECT TRUNC(to_date(#{thisTime},'YYYY-MM-DD'), 'MONTH') + LEVEL - 1 AS FDATE
FROM DUAL
CONNECT BY LEVEL <= 31) T
WHERE TO_CHAR(FDATE, 'MM') = TO_CHAR(to_date(#{thisTime},'YYYY-MM-DD'), 'MM')) A
LEFT JOIN (SELECT STARTDATE, ENDDATE
FROM GBJXKH_V_DAILYTASK
WHERE USERID = #{user001}) B
ON TRUNC(B.STARTDATE) <= A.FDATE
AND TRUNC(B.ENDDATE + 1) > A.FDATE
GROUP BY A.FDATE
ORDER BY A.FDATE
SELECT 10 + LEVEL*10 AS FDATE
FROM DUAL
CONNECT BY LEVEL <= 10