You have explicitly defined the column order with
SELECT
Leave,
ISNULL([1], 0) AS January,
ISNULL([2], 0) AS February,
ISNULL([3], 0) AS March,
ISNULL([4], 0) AS April,
ISNULL([5], 0) AS May,
ISNULL([6], 0) AS June,
ISNULL([7], 0) AS July,
ISNULL([8], 0) AS August,
ISNULL([9], 0) AS September,
ISNULL([10], 0) AS October,
ISNULL([11], 0) AS November,
ISNULL([12], 0) AS December
FROM
So in theory all you have to do is
SELECT
Leave,
ISNULL([3], 0) AS March,
ISNULL([4], 0) AS April,
ISNULL([5], 0) AS May,
ISNULL([6], 0) AS June,
ISNULL([7], 0) AS July,
ISNULL([8], 0) AS August,
ISNULL([9], 0) AS September,
ISNULL([10], 0) AS October,
ISNULL([11], 0) AS November,
ISNULL([12], 0) AS December,
ISNULL([1], 0) AS January,
ISNULL([2], 0) AS February
FROM
Note similarly, the order that the columns will be returned from your pivot is defined by
FOR Months IN ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12])
But I suspect there is a bit more to it than that - are you asking that the order should be "start from the month defined in
mte.CalendarDate BETWEEN '2023-02-27' AND GETDATE()
(i.e. in this case March) and order the subsequent months through to the following March?
If that is the case then you may need to use a Dynamic SQL statement - I described a similar scenario in my article
Processing Loops in SQL Server[
^]