美文网首页
(按月份统计统计)Mysql根据时间的月份进行分组查询

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

作者: 空口言_1d2e | 来源:发表于2020-05-14 14:00 被阅读0次

    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根据时间的月份进行分组查询

          本文链接:https://www.haomeiwen.com/subject/dvyzxhtx.html