Order By

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc

Poston Thu, 28 Jun 2007 2:46 pm

Good afternoon, I need to make an order by unconventional, I don't know if it's possible. E.g. I have a numeric field qualquer, it have the following values 1.2 .3 .4 .5 .6.
Need to bring the result sorted first by 4, then by 6, then 1 etc. ..

Does anyone know how to do this?
Location: RS

Poston Thu, 28 Jun 2007 3:54 pm

In the end it was quite simple. To posting to if anyone interested ... order by case when Field_Name = 4 then 1 when Field_Name = 6 then 2 ...
Location: RS

Poston Fri, 29 Jun 2007 9:15 am

Or, you can use DECODE
Code: Select all
  DECODE( seu_campo, 4, 1
                   , 6, 2
                      , 99 )
in this way, he will \"transform\" the 4:0 pm, 6:0 pm 1 2, and the rest in 99 in order by.
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?

  • See also
    Last Post

Return to SQL

Who is online

Users browsing this forum: No registered users and 6 guests