Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-04-21 : 10:20:18
|
| Srinivas writes "Hi , Can we write a query to do the following.Country_id Country_name----------- --------------120 USA118 UK100 Argentina102 Alabama103 Bangladesh104 Canada and so onIt is required that USA and UK are always on the topand the rest of the countries are ordered by country name in ascending orderAny Pointers?REgardssrinivas" |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-04-21 : 10:28:29
|
| CREATE TABLE #Country(CountryID INT, CountryDesc VARCHAR(200))INSERT INTO #Country VALUES(120,'USA')INSERT INTO #Country VALUES(118, 'UK')INSERT INTO #Country VALUES(100, 'Argentina')INSERT INTO #Country VALUES(102, 'Alabama')INSERT INTO #Country VALUES(103, 'Bangladesh')INSERT INTO #Country VALUES(104, 'Canada')select CountryID, CountryDesc, CASE WHEN CountryID = 120 then 0 WHEN CountryID = 118 THEN 1 ELSE 2 END as sidFROM #CountryORDER BY 3, 2Duane. |
 |
|
|
|
|
|