Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equivalent of Oracle Decode in Order by clause

Status
Not open for further replies.

BadRabbit

Programmer
Nov 14, 2002
28
GB
Hi, I'm bring back some username records and I want to order them alphabetically but I always want the record containing the word "General" to come last.

In Oracle it's easy:

SELECT...FROM...WHERE...
ORDER BY DECODE(my_field,"General","ZZZZZ",my_field)

Does anyone know how to do it in SQL Server 2000?

Thanks.
 
Hi,

Try this... Have a look at CASE statement..

SELECT * FROM tbl
ORDER BY
CASE my_field when 'General'
Then 'ZZZZZZ'
ELSE my_field
END



Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top