SELECT TYPE , SUM( amount ) AS total FROM db_transaction WHERE Username = 'test'
AND YEAR( FROM_UNIXTIME( db_transaction.transaction_date ) ) = '2013'
GROUP BY TYPE , MONTH( FROM_UNIXTIME( db_transaction.transaction_date ) )
ORDER BY transaction_date,TYPE ASC
TYPE total
0 14000
1 1000
0 8000
1 500
0 4000
1 100