首页 > 数据库技术 > 详细

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

时间:2017-08-15 20:31:34      阅读:252      评论:0      收藏:0      [点我收藏+]

技术分享

关于进行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";

  

 

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

原文:http://www.cnblogs.com/lhwhqy/p/7366944.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!