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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do extend the use of Order by Clause 1

Status
Not open for further replies.

craigscott

Programmer
Joined
Oct 10, 2001
Messages
2
Location
GB
Hello,

I have the following SQL Table

CREATE TABLE [dbo].[country_lookup] (
[country_id] [int] IDENTITY (1, 1) NOT NULL ,
[country_code] [varchar] (50) NULL ,
[country_name] [varchar] (50) NULL ,
[country_dialcode] [varchar] (50) NULL
) ON [PRIMARY]


I am trying to write a single query to order the results set so I can get a particular country_id First, then the rest ordered after it.

Something along the lines of:-

SELECT * FROM country_lookup ORDER BY country_id = 289, country_name

With no luck,


Any Ideas on a solution, situation requires not to use a Stored Procedure.

Cheers


Craig
 

Order By
Case
When Country_Id=289 Then 0
Else 1
End,
Country_Name Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Your a Star,


That worked a treat.


Cheers


Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top