select
DATE_FORMAT(CREATED_DT,'%Y-%m') months, count(SID) count
from ***
where
1 = 1 and DATE_FORMAT(CREATED_DT,'%Y-%m') > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m')
group by months
截图:
select
DATE_FORMAT(CREATED_DT,'%Y-%m') months, count(SID) count
from ***
where
1 = 1 and DATE_FORMAT(CREATED_DT,'%Y-%m') > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m')
group by months
截图: