I have a column of lets say 10 values all NCHAR(20) in SQL Server.
I want to sort the Values by the 2nd Letter in a Descending manner. In other Words if i have the following column values. Note this should work with any values this is just examples.
The SQL Query must produce the Following Output
The closest I could come to an answer was This -
Select planet, name from galaxy WHERE planet like '_%' ORDER BY planet desc
ORDER BY SUBSTRING(planet , 2, 1) DESC
It`s good to check the docs from time to time Link
You can ORDER BY SUBSTR(planet, 2) DESC
This means minus the first character.
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