【发布时间】:2009-12-05 00:25:46
【问题描述】:
我有一个查询如下。
select strftime('%Y-%m',A.traDate) as Month,sum(A.TraAmt) as Total,C.GroupType from
TransactionTbl A left join TransactionCategory B on A.CategoryID = B.CategoryID left join
CategoryGroup C on B.CatGRoupID=C.CatGRoupID where A.UserID=1 and A.ProfileID=1 and
date(A.TraDate) between date('2009-12-01') and date('2010-11-01') group by C.GroupType,
strftime('%m',A.traDate) order by Month
上面的查询给出的结果如下,
Month Total C.GroupType
----- ----- -----------
2009-12 4100 Expense
2009-12 8000 Income
2010-01 200 Expense
2010-01 2000 Income
2010-02 3500 Expense
2010-02 7500 Income
我想要这样的解决方案。
Month Income Expense
----- ----- -----------
2009-12 8000 4100
2010-01 8000 200
2010-02 7500 3500
我正在努力获得这样的输出,但我可以找到任何类型的解决方案。
【问题讨论】: