Reverse ordering SQL [closed]

0

Is it possible to sort the codes of a select inverted?

Example:

As the last number of the first element is smaller it comes first and for tie criterion the second decade will be checked, as well as in the normal ordering, but as informed, in reverse.

1st = 58 95 52

2nd = 56 84 55 ...

    
asked by anonymous 15.05.2018 / 18:57

3 answers

1

If you use a SUBSTR just picking up the last ten and then the hundreds and then thousands ... You could do the ordering of each one and put it together at the end.

SUBSTR(CODIGO, -2,1)
    
22.05.2018 / 15:27
4

Yes, only use the reserved word desc .

Select Coluna From Tabela
Order By Coluna Desc;
    
15.05.2018 / 19:02
1

If you have a table that in each row stores 3 tens, just put the fields in the order by, for example:

SELECT d.dezena3, d.dezena2, d.dezena1 FROM dezena d
ORDER BY d.dezena3, d.dezena2, d.dezena1
    
15.05.2018 / 19:25