MySql按日期进行统计(前一天、本周、某一天)![]() 统计当天 date_sub(curdate(),interval -1 year) 默示 2014-05-20
如: <!-- 分页查询订单个数 --> <select id="queryOrderCountByCondition" resultClass="order"> select count(*) as id from t_order_info<dynamic prepend="where"> <isNotNull prepend="and" property="companyId"> company_id = #companyId# </isNotNull> <isNotNull prepend="and" property="inMonth"> date_sub(CURDATE(), INTERVAL 1 MONTH) <= date(add_time) </isNotNull>
<isNotNull prepend="and" property="productName"> id in (select id from t_order_info where id in(select order_id from t_order_product where product_id in(SELECT t_product.id FROM t_product where t_product.name=#productName#))) </isNotNull>
<isNotNull prepend="and" property="orderDateBegin"> <![CDATA[ add_time >= #orderDateBegin#]]> </isNotNull> <isNotNull prepend="and" property="orderDateEnd"> <![CDATA[ add_time <= #orderDateEnd#]]> </isNotNull> </dynamic> </select> |
上海网站建设Copyright 2005-2010 All Rights Reserved 地址:上海市天云路259号 电话:021-57700304 传真:57661889 沪ICP备05011021号 |
转载于:https://blog.51cto.com/1008610086/1268489