SELECT DATE_FORMAT( TRANS_TIME, "%Y-%m-%d" ),SUM(SUM) FROM ibsp_pay_bill WHERE TRANS_TIME>"2018-02-05 00:00:00" AND TRANS_TIME<"2018-03-05 23:59:59" AND COMPARE_SIGN="支付正常" GROUP BY DATE_FORMAT( TRANS_TIME, "%Y-%m-%d" )
结果:
查询某天:
TRANS_TIME, "%Y-%m-%d"
某时:
TRANS_TIME, "%Y-%m-%d %H"
依次类推。
其实就是对dateline进行处理,然后再对处理后的数据分组
附:mysql ORDER BY,GROUP BY 和DISTINCT原理
http://www.cnblogs.com/ggjucheng/archive/2012/11/18/2776449.html