I have a table called payhistory
, and from this table I need to grab the Year
, Month
when a payment was made. I then need to get an average of payments grouped by Year and then month.
select AVG(totalpaid) from payhistory
This table has a column called datepaid
that is where I need to grab the date from. It has a column called totalpaid
which is where I need to grab the average from.
I then need a count of every payment within that month.
And finally a column displaying which Year/Month it was from.
Important columns in the table:
number
(account number can use this to get a count)datepaid
(contains the date the payment was entered '2009-09-28 00:00:00.000')totalpaid
(contains the specific payment for that date)