SQL Order by Second Letter of Column Name
sql, sql-server
Solution
ORDER BY SUBSTRING(planet , 2, 1) DESC
It`s good to check the docs from time to time Link
Problem
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. - Earth - Space - Moon - Star - Pluto The SQL Query must produce the Following Output - Star - Space - Moon - Pluto - Earth The closest I could come to an answer was This - Select planet, name from galaxy WHERE planet like '_%' ORDER BY planet desc