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
how to combine 2 different table?
If there is a unique constraint on
exp_cat.cat_name, then you can eliminate the Group By clause.Given that this is Access, it may be more efficient in the long run to create two stored queries for cash and cheque grouped by
exp_cat.cat_name. Then you could write something like:Each of the two queries would look like: