Hey all,
I am using this query using UNION, where both fields that contains the amount are combined into one table, and i wanted to split them into 2 fields, first for cash and other for cheque
SELECT exp_cat.cat_name, SUM(exp_cheque.exp_amount) AS Cheque
FROM exp_cat INNER JOIN exp_cheque ON exp_cat.ID = exp_cheque.exp_cat_id
GROUP BY exp_cat.cat_name;
UNION
SELECT exp_cat.cat_name, SUM(exp_cash.exp_amount) As Cash
FROM exp_cat INNER JOIN exp_cash ON exp_cat.ID = exp_cash.exp_cat_id
GROUP BY exp_cat.cat_name;
Please use this link to understand the each table structure http://stackoverflow.com/questions/3260980/how-to-combine-2-different-table