left join on

2018-08-24 15:42:19.0

主页 / 学习 / left join on

40

SELECT
b.dd date,
COUNT(a.id) count
FROM
ev_statistics_calendar b
LEFT JOIN (
SELECT
id,createTime
FROM
ev_event
WHERE
delete_flag = "1"
AND qxOrgName = "镇海区"
AND source = "zf"
) a ON DATE_FORMAT(a.createTime, '%Y-%m-%d') = b.dd
WHERE
b.dd BETWEEN DATE_SUB(curdate(), INTERVAL 30 DAY)
AND DATE_SUB(curdate(), INTERVAL 0 DAY)
GROUP BY
b.dd
ORDER BY

b.dd ASC