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
 sorts the column without keyword Order By
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

teamjai
Starting Member

India
42 Posts

Posted - 01/24/2013 :  02:31:39  Show Profile  Reply with Quote
By default, ORDER BY sorts the column in ascending order.

i need to sort the column Without ORDER BY keyword in the SQL query, is it possible in SQL server 2008

Eg:
Select Seq.No from Student Order By Seq.No

it display Seq.No in Asc order.

bandi
Flowing Fount of Yak Knowledge

India
2170 Posts

Posted - 01/24/2013 :  02:42:24  Show Profile  Reply with Quote
GROUP BY clause also sorts the results. Difference is duplicates will be removed from the list

If there is no duplicates for the column Seq.No , then GROUP BY will also give result in ascending order

1) Select Seq.No from Student Order By Seq.No

2) Select Seq.No from Student GROUP By Seq.No



--
Chandu

Edited by - bandi on 01/24/2013 02:45:20
Go to Top of Page

teamjai
Starting Member

India
42 Posts

Posted - 01/24/2013 :  03:15:31  Show Profile  Reply with Quote
Thanks..

But i need use only "Where".
Using "where" keyword sorts the results. is it possible?
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8683 Posts

Posted - 01/24/2013 :  03:40:12  Show Profile  Visit webfred's Homepage  Reply with Quote
NO, there is no reliable order without using ORDER BY!


Too old to Rock'n'Roll too young to die.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2170 Posts

Posted - 01/24/2013 :  03:45:31  Show Profile  Reply with Quote
quote:
Originally posted by teamjai

Thanks..
But i need use only "Where".
Using "where" keyword sorts the results. is it possible?

I guess that is not possible....

--
Chandu
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.04 seconds. Powered By: Snitz Forums 2000