使用不同的日期获得不同总数的总和

时间:2015-10-22 14:52:50

标签: mysql

我有一个交易表,我想要总结不同日期的总金额,贝娄是我的代码

SELECT SUM( total_amount ) AS total FROM transaction WHERE execution_date BETWEEN  "2015-08-1" AND  "2015-08-31" AND execution_date BETWEEN  "2015-09-1" AND  "2015-09-30"

代码只返回Null。欢迎任何帮助。

1 个答案:

答案 0 :(得分:0)

您应该<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 代替OR。由于您希望显示AND2015-08-1" AND "2015-08-31范围内的交易, 哪个是矛盾,结果2015-09-1" AND "2015-09-30

null

OR

SELECT SUM( total_amount ) AS total FROM transaction
 WHERE execution_date BETWEEN "2015-08-1" AND "2015-08-31" 
OR execution_date BETWEEN "2015-09-1" AND "2015-09-30"

希望这有帮助