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?
capellao
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 ...
capellao
Location: RS

Poston Fri, 29 Jun 2007 9:15 am

Or, you can use DECODE
Code: Select all
ORDER BY
  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.
:-o
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered


  • See also
    Replies
    Views
    Last Post


Return to SQL

Who is online

Users browsing this forum: Google [Bot] and 3 guests