tags:

views:

42

answers:

1
+3  Q: 

Order by in SQL

Is it possible to order a query result based on 2 columns with the first sorting ascending on column1 and the secondary sort on column2 in desc?

select * from table1 orderby column1, column2

I believe this SQL statement should work, would adding desc along with the second column work or is there any better way of doing it?

+10  A: 

yes

select * from table1 orderby column1 asc , column2 desc
John Nolan
Thanks, is asc necessary?, by default its asc. correct me if i am wrong
Prady
nope asc is not necessary.
Sem Dendoncker
The asc on column is not necessary but it adds clarity. Without the asc a user may wrongly assume column1 is also being sorted in descending order; with there is no confusion.
John Nolan
Thanks tat was informative
Prady