Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Table A:
- * Created At
- * Amount Charged
- Table B:
- * Created At
- * Cash Amount
- SELECT str_to_date(concat(date_format(created_at, '%Y-%m'), '-01'), SUM(sub.c)
- FROM (SELECT CreatedAt, Amount AS c
- FROM tabA
- UNION ALL CreatedAt, Cash
- FROM tabB) sub
- GROUP BY str_to_date(concat(date_format(created_at, '%Y-%m'), '-01');
Add Comment
Please, Sign In to add comment