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
dimis283
Messages: 38
Registered: July 2007
Location: greece
Member
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.
As
a                 b                    c
1              something              some
1              something              some
1                else                 any
2              something              any
2                else                 any


How Can I do it?
Dimis

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

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

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



regards,
Previous Topic: Query required
Next Topic: problem with substitution vairable
Goto Forum:
  


Current Time: Wed Dec 07 04:53:26 CST 2016

Total time taken to generate the page: 0.10347 seconds