I have a simple query that sums sales totals for September and compares them with Sept of last year. How can I write this so that it auto updates with the current month month each month?
SUM(CASE WHEN InvoiceDate Between '2015-9-1' and '2015-9-30' THEN Totsales else 0 end) as Sales15,
SUM(CASE WHEN InvoiceDate Between '2016-9-1' and '2016-9-30' THEN Totsales else 0 end) as Sales16
Group by Salesman
This is part of a PHP script so if there's a better/easier way to do it in PHP I'd be happy to hear about that as well.