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
 Sorting by several columns

Author  Topic 

robert323
Starting Member

3 Posts

Posted - 2006-07-24 : 16:41:41
Hello all,
I'm verry new to SQL server, and find myself trying to sort a table ascendingly be several columns. For instance:

SELECT * FROM Sort ODER BY start_year AND start_month ASC

I've tried to run this, but it simply does not work.

Is there a simple way to do something like this?

Any help is greatly appreciated! Thanks so much
-Robert

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-07-24 : 16:45:11
"ODER BY"?

You might try it like this:

ORDER BY
start_year,
start_month


CODO ERGO SUM
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-07-25 : 03:07:05
Just a small addition...you can sort the different columns in different directions:

SELECT * FROM Sort ORDER BY start_year DESC, start_month ASC

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-26 : 10:49:14
Also, Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -