SQL order by second column name

I have a column that allows me to say 10 values ​​of all NCHAR (20) in SQL Server.

I want to sort the values ​​by the 2nd letter in descending order. In other words, if I have the following column values. Note that this should work with any values, these are just examples.

  • Earth
  • Space
  • Moon
  • Star
  • Pluto

SQL Query should produce the following output

  • Star
  • Space
  • Moon
  • Pluto
  • Earth

The closest I could answer to was This -

Select a planet, the name from the galaxy WHERE is the planet as _ _% ORDER BY planet desc

+3
source share
2 answers
ORDER BY SUBSTRING(planet , 2, 1) DESC

It’s good to check documents from time to time Link

+4
source

You can ORDER BY SUBSTR(planet, 2) DESC

This means minus the first character.

+1
source

All Articles