I'm joining two tables of information that both have a datetime field called "report_date".
I'd like to group the results by year and month but still need to include the report_date field from at least one of the tables for the purpose of drawing out a chart. The actual day or time of the report_date doesn't matter, just the month and year.
My current query looks something like this but certainly is incorrect:
YEAR(`usage`.`report_date`) as report_year,
MONTH(`usage`.`report_date`) as report_month,
`usage`.`number` as usage,
`authorizations`.`number` as authorizations
`usage`.`report_date` as report_date
INNER JOIN `database`.`authorizations`
ON (`usage`.`site` = `authorizations`.`site`)
GROUP BY report_year, report_month
In the end I would have something like:
2014	 1	 2014-01-05	 15	 14
2014	 2	 2014-02-17	 20	 21