I have Below Table named session
SessionID SessionName
100 August
101 September
102 October
103 November
104 December
105 January
106 May
107 June
108 July
I executed the following query I got the output as below.
Select SessionID, SessionName
From dbo.Session
SessionID SessionName
100 August
101 September
102 October
103 November
104 December
105 January
106 May
107 June
108 July
the results get ordered by Session ID. But I need the output as below,
SessionID SessionName
106 May
107 June
108 July
100 August
101 September
102 October
103 November
104 December
105 January
How to achieve this in sql-server? thanks for the help
I'd use a case expression, like:
order by case SessionName when 'August' then 1
when 'September' then 2
...
when 'Juty' then 12
end
August has 1 because "in the application logic a session started with august", easy to renumber if you want to start with January and end with December.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With