0
我想了解我的數據庫中每月的餘額摘要。該表具有以下字段SQLite ROLLUP查詢
tran_date
type (Income or Expense)
amount
我能得到儘可能獲取總和爲每種類型的每個月,但希望整個月的總和。這是我當前的查詢:
SELECT DISTINCT strftime('%m%Y', tran_date), type, SUM(amount) FROM tran WHERE exclude = 0 GROUP BY tran_date, type
這將返回
032013 Income 100
032013 Expense 200
我想在一行的總結,在這個例子中032013 -100。
謝謝!我只是不確定如何計算這兩種類型。 – Carl