Hi Experts,

I have the following query which works fine. I just need to figure out how to sort by Month order instead of having months sorted alphabetically. I'm sure there is a simple way to do this but I can't think of anything.

Appreciate your help

Query is:

SELECT DATENAME(MM,[SubmissionDat

e]) as MonthName

,DATEPART(YEAR,[SubmissionDate]) as YearName

,SUM(CASE R.BranchID WHEN 1 THEN 1 ELSE 0 END) Riyadh

,SUM(CASE R.BranchID WHEN 2 THEN 1 ELSE 0 END) Jeddah

,SUM(CASE R.BranchID WHEN 3 THEN 1 ELSE 0 END) Dammam

,SUM(CASE WHEN R.BranchID ='1' OR R.BranchID ='2' OR R.BranchID ='3' THEN 1 ELSE 0 END) as Total

FROM [STR].[dbo].[ILicensesRenewApplications]R

WHERE StatusID <> 1

Group by DATENAME(MM,[SubmissionDate]),DATEPART(YEAR,[SubmissionDate])

UNION

SELECT 'Sum' MonthName

,' ' YearName

,SUM(CASE R.BranchID WHEN 1 THEN 1 ELSE 0 END) Riyadh

,suM(CASE R.BranchID WHEN 2 THEN 1 ELSE 0 END) Jeddah

,SUM(CASE R.BranchID WHEN 3 THEN 1 ELSE 0 END) Dammam

,SUM(CASE WHEN R.BranchID ='1' OR R.BranchID ='2' OR R.BranchID ='3' THEN 1 ELSE 0 END) as Total

FROM [STR].[dbo].[ILicensesRenewApplications]R

WHERE StatusID <> 1

order by MonthName, YearName