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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select india 1st and then others sort asc

Author  Topic 

shanmugaraj
Posting Yak Master

219 Posts

Posted - 2013-01-01 : 02:45:14
I have Country Table with all the countries.
i want to select country "India" in first row then following by all the countries order by ascending
kindly help me on the query below to make the same..

Select Country_Name form TblCountry order by Country_Name Asc


THANKS
SHANMUGARAJ
nshanmugaraj@gmail.com

shenulal
Starting Member

11 Posts

Posted - 2013-01-01 : 06:23:01
select 'India' as Country
union
Select CountryName as Contry from Country
Go to Top of Page

shenulal
Starting Member

11 Posts

Posted - 2013-01-01 : 06:23:37
select 'India' as Country
union
Select CountryName as Contry from Country
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2013-01-01 : 09:55:55
Select Country_Name
FROM TblCountry
order by CASE WHEN Country_Name='India' THEN 1 ELSE 0 END DESC, Country_Name Asc

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-03 : 01:14:16
quote:
Originally posted by shenulal

select 'India' as Country
union
Select CountryName as Contry from Country



this will not still guarantee order starting with India

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -