首页 > 数据库技术 > 详细

按月、按日进行数据统计的Mysql语句

时间:2016-11-08 13:24:54      阅读:190      评论:0      收藏:0      [点我收藏+]
<select id="getCustomerTJByUser" parameterType="map" resultType="map">
select u.username,
<if test="dateType==&quot;d&quot;">DATE_FORMAT(c.create_date,‘%Y-%m-%d‘) createDate,</if>
<if test="dateType==&quot;m&quot;">DATE_FORMAT(c.create_date,‘%Y-%m‘) createDate,</if>
COUNT(*) summer
from nb_custom c ,nb_user u
where 1=1
<if test="startDate!=null&amp;&amp;startDate!=&quot;&quot;"> and c.create_date &gt;= #{startDate}</if>
<if test="endDate!=null&amp;&amp;endDate!=&quot;&quot;"> and c.create_date &lt;= #{endDate}</if>
<if test="usernameTJ!=null&amp;&amp;usernameTJ!=&quot;&quot;"> and u.username=#{usernameTJ}</if>
<if test="createId!=null"> and u.create_id=#{createId}</if>
and u.state=1
and c.nu_id_oper=u.nu_id
GROUP BY createDate,u.username
</select>

按月、按日进行数据统计的Mysql语句

原文:http://www.cnblogs.com/xiaonier/p/6042488.html

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