SQL查询将数据按字段(2017-08-15 11:34:05)进行按月分组

关于进行sql查询按字段me_createTime按月进行排序

使用函数:date_format 按月进行分组查询,并按月进行排序

上代码

$sql="select date_format(me_createTime,'%Y-%m')as create_month,count(me_id) as me_num from {$SETTING['db']['prefix']}member where me_state in(1,2) and sm_id='$sm_id' group by date_format(me_createTime,'%Y-%m') order by date_format(me_createTime,'%Y-%m') desc";

  

不断的修改不断的完善
原文地址:https://www.cnblogs.com/lhwhqy/p/7366944.html