0
+------------+------+-----------------------+
| invoice | amount | paid | date |
+------------+--------+--------+------------+
| 1001 | 55 | 1 | 2015-01-01 |
+------------+--------+--------+------------+
| 1002 | 30 | 0 | 2015-02-01 |
+------------+--------+--------+------------+
| 1003 | 59 | 1 | 2015-02-01 |
+------------+--------+--------+------------+
| 1004 | 78 | 0 | 2015-03-01 |
+------------+--------+--------+------------+
| 1005 | 65 | 1 | 2015-03-01 |
+------------+--------+--------+------------+
| 1006 | 107 | 0 | 2015-04-01 |
+------------+--------+--------+------------+
例如,如果我有上面的表, 我想獲取總髮票金額和付款金額。mysql,子查詢或按條件加入組
總髮票金額
select sum(amount) from invoice group by DATE_FORMAT(date,"%Y-%m")
來支付發票
select sum(amount) from invoice where paid=1 group by DATE_FORMAT(date,"%Y-%m")
我怎樣才能結合成單一的查詢?