(按月份统计统计)Mysql根据时间的月份进行分组查询

create_time时间格式

    SELECT DATE_FORMAT(create_time,'%Y%u') weeks FROM student GROUP BY weeks;  
    SELECT DATE_FORMAT(create_time,'%Y%m%d') days FROM student GROUP BY days;   
    SELECT DATE_FORMAT(create_time,'%Y%m') months FROM student GROUP BY months

create_time时间戳格式

    SELECT FROM_UNIXTIME(create_time,'%Y%u') weeks FROM student GROUP BY weeks;  
    SELECT FROM_UNIXTIME(create_time,'%Y%m%d') days FROM student GROUP BY days;   
    SELECT FROM_UNIXTIME(create_time,'%Y%m') months FROM student GROUP BY months

原文链接:https://blog.csdn.net/qq502948261/article/details/89969014

你可能感兴趣的:((按月份统计统计)Mysql根据时间的月份进行分组查询)