Guest User

Untitled

a guest
Jun 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. Table A:
  2. * Created At
  3. * Amount Charged
  4.  
  5. Table B:
  6. * Created At
  7. * Cash Amount
  8.  
  9. SELECT str_to_date(concat(date_format(created_at, '%Y-%m'), '-01'), SUM(sub.c)
  10. FROM (SELECT CreatedAt, Amount AS c
  11. FROM tabA
  12. UNION ALL CreatedAt, Cash
  13. FROM tabB) sub
  14. GROUP BY str_to_date(concat(date_format(created_at, '%Y-%m'), '-01');
Add Comment
Please, Sign In to add comment