SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select india 1st and then others sort asc
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

shanmugaraj
Posting Yak Master

212 Posts

Posted - 01/01/2013 :  02:45:14  Show Profile  Send shanmugaraj a Yahoo! Message  Reply with Quote
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

India
11 Posts

Posted - 01/01/2013 :  06:23:01  Show Profile  Reply with Quote
select 'India' as Country
union
Select CountryName as Contry from Country
Go to Top of Page

shenulal
Starting Member

India
11 Posts

Posted - 01/01/2013 :  06:23:37  Show Profile  Reply with Quote
select 'India' as Country
union
Select CountryName as Contry from Country
Go to Top of Page

lionofdezert
Aged Yak Warrior

Pakistan
885 Posts

Posted - 01/01/2013 :  09:55:55  Show Profile  Visit lionofdezert's Homepage  Send lionofdezert a Yahoo! Message  Reply with Quote
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

India
52249 Posts

Posted - 01/03/2013 :  01:14:16  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000