select DATE_FORMAT(create_date,'%Y%u') weeks,count(event_id) count from t_alarm_event where create_date > '2015-10-22' and (event_type = 12 or event_type=13) group by weeks;
select DATE_FORMAT(create_date,'%Y%m%d') days,count(event_id) count from t_alarm_event where create_date > '2015-10-22' and (event_type = 12 or event_type=13) group by days;
select DATE_FORMAT(create_date,'%Y%m') months,count(event_id) count from t_alarm_event where create_date > '2015-10-22' and (event_type = 12 or event_type=13) group by months;
MySQL按周、按日和按月分組統計數據
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.