MySQL To Show Month Over Month Data By Year How can I change this query to show data in this format

01-18  2000
01-19  4000
02-18  3000
02-19  1000


This is the syntax I have but since it's union I can't use an order by clause

SELECT DATE_FORMAT(salesdate, "%m-%Y") AS Month, employeeName,    SUM(saleAmount)
FROM  prevyear
WHERE BDM = 'Jason Hernandez'
GROUP BY DATE_FORMAT(salesdate, "%m-%Y"), employeeName
UNION ALL 
SELECT DATE_FORMAT(salesdate, "%m-%Y") AS Month, employeeName, SUM(saleAmount)
FROM  curryear
WHERE BDM = 'Jason Hernandez'
GROUP BY DATE_FORMAT(salesdate, "%m-%Y"), employeeName
You could wrap a new query around this one to allow you to aggregate the results:

SELECT Month, SUM(salesAmount) FROM (
    SELECT DATE_FORMAT(salesdate, "%m-%Y") AS Month, employeeName,    SUM(saleAmount)
    FROM  prevyear
    WHERE BDM = 'Jason Hernandez'
    GROUP BY DATE_FORMAT(salesdate, "%m-%Y"), employeeName
    UNION ALL 
    SELECT DATE_FORMAT(salesdate, "%m-%Y") AS Month, employeeName, SUM(saleAmount)
    FROM  curryear
    WHERE BDM = 'Jason Hernandez'
    GROUP BY DATE_FORMAT(salesdate, "%m-%Y"), employeeName
) previousQuery
GROUP BY Month


Ideally I'd build the query to do this in one go rather than turning your query into a subquery but it will work. Here's an example that shows it working.