首页 > 其他 > 详细

年,季度,月,周数据查询

时间:2020-09-18 09:04:02      阅读:63      评论:0      收藏:0      [点我收藏+]
<select id="getSaleData" resultType="map"> SELECT FORMAT((SUM(t.totalMoney)/10000), 2) AS totalMoney, SUM(t.amount) AS totalAmount, <if test="type != null and type != ‘‘ and type==‘year‘"> date_format(t.addTime,‘%Y‘) as riqi </if> <if test="type != null and type != ‘‘ and type==‘season‘"> QUARTER(t.addTime) as riqi </if> <if test="type != null and type != ‘‘ and type==‘month‘"> date_format(t.addTime,‘%Y-%m‘) as riqi </if> <if test="type != null and type != ‘‘ and type==‘week‘"> date_format(t.addTime, ‘%Y-%m-%d‘) as riqi </if> FROM destoon_orderform t WHERE 1 = 1 AND t.orderStatus != ‘90‘ <if test="type != null and type != ‘‘ and type==‘year‘"> GROUP BY date_format(t.addTime,‘%Y‘) </if> <if test="type != null and type != ‘‘ and type==‘season‘"> AND date_format(t.addTime,‘%Y‘)=date_format(now(),‘%Y‘) GROUP BY QUARTER(t.addTime) </if> <if test="type != null and type != ‘‘ and type==‘month‘"> AND date_format(t.addTime,‘%Y‘)=date_format(now(),‘%Y‘) GROUP BY date_format(t.addTime,‘%Y-%m‘) </if> <if test="type != null and type != ‘‘ and type==‘week‘"> AND YEARWEEK(date_format(t.addTime,‘%Y-%m-%d‘)) = YEARWEEK(now()) GROUP BY date_format(t.addTime, ‘%Y-%m-%d‘) </if> </select>

年,季度,月,周数据查询

原文:https://blog.51cto.com/brightaries/2534784

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