I am a mysql newbie here need some help with a sql query I cant quite figure out.
I currently have a table Transact that contains something like this:
Paytype Amount Date
Cash 100.0 2013-08-01
Visa 50.00 2013-09-2
Check 50.00 2013-11-12
Cash 75.00 2013-12-01
Cash 50.00 2013-12-19
Visa 100.00 2014-3-01
Cash 20.00 2014-5-20
Amount and Pay type ordered based on transaction dates, I want it to be queried out into a table that gives sum of the amount for each paytype and grouped by paytype like this:
Paytype Total
Cash 245.00
Visa 100.00
Check 50.00
Having it based off a date range so say I want that based by 2013-12-15 to 2014-5-01. Currently I can just get out one single sum for a specific paytype with
select paytype, (SUM(IF(paytype = 'Cash', Amount, 0)) from Transact group by paytype.
Please help with the proper query to execute that! Thanks much!