Excerpts from Barton Chittenden's message of 2017-03-06 08:08:04 -0500:
I'll do the 'month, by year'; the 'day by month' one will follow the same pattern.
SELECT monthname(datetime), SUM( IF(type = 'issue'), 1, 0 ) as issues, SUM( IF(type = 'renew'), 1, 0 ) as renewals, SUM( IF(type = 'return'), 1, 0 ) as returns FROM statistics WHERE YEAR(datetime) = YEAR(current_date) AND MONTH(datetime) = MONTH(current_date)
I haven't actually run this; there may be typos, but it should be pretty close.
Pretty close! Just some misplaced parens: SELECT monthname(datetime), SUM( IF(type = 'issue', 1, 0 )) as issues, SUM( IF(type = 'renew', 1, 0 )) as renewals, SUM( IF(type = 'return', 1, 0 )) as returns FROM statistics WHERE YEAR(datetime) = YEAR(current_date) AND MONTH(datetime) = MONTH(current_date)