I am trying to create a query that calculates credit and debit for each month. the values are in column called SUM and there is a field for each record that says if it is credit or debit (ex_type). I have manage to get the total sum of all the fields (although it is not correct as well - cos I am just sum all the values no matter if it is credit or debit).
SELECT sum(sum) as total FROM acc where month='$month'
But I cannot figure out for to do it for Credit and Debit
So, to summarize... I want to have the following two queries combined in one.
1. Select sum(sum) as Debit from acc where ex_type='Debit' and month='$month'
2. Select sum(sum) as Credit from acc where ex_type='Credit' and month='$month'
So, any help is much appreciated.