I’m confused about this:
SELECT request_id, SUM( cc_amount ) AS amt,
DATE_FORMAT( transaction_datetime, '%b %y' ) AS tdate
FROM ee_request_cc
GROUP BY DATE_FORMAT( transaction_datetime, '%b %y' )
UNION
SELECT request_id, SUM( request_amount ) AS amt,
DATE_FORMAT( transaction_date, '%b %y' ) AS tdate
FROM ee_request_paypal
GROUP BY DATE_FORMAT( transaction_date, '%b %y' )
I’m getting:
id amt tdate
20 86.00 Mar 12
80 5.00 Apr 12
23 55.00 Mar 12
Whereas I want to add all amounts for March and April like:
id amt tdate
20 141.00 Mar 12
80 5.00 Apr 12
Please suggest me the change in my query.
You need to get all the results, and then perform the aggregation: