Home » SQL & PL/SQL » SQL & PL/SQL » sql order by
sql order by [message #275906] Tue, 23 October 2007 05:34 Go to next message
Messages: 38
Registered: July 2007
Location: greece
I have this query
select a,b ,c
from mytable 
where a in (1,2,3)
order by a

I want to order the results by a and then the results of the query having b="something" for example to be fetched first of all others.
a                 b                    c
1              something              some
1              something              some
1                else                 any
2              something              any
2                else                 any

How Can I do it?

Re: sql order by [message #275907 is a reply to message #275906] Tue, 23 October 2007 05:44 Go to previous message
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member

you can use the decode to achive your desired output.something like

select .....
order by a,decode(b,'something',1,2)

Previous Topic: PL/SQL table Searching logic
Next Topic: about USERENV('SESSIONID')
Goto Forum:

Current Time: Sun Aug 20 19:58:36 CDT 2017

Total time taken to generate the page: 0.08704 seconds