Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an table into sql server database which contain some columns and i put an select statment and now i want to use order by clause on more then one columns then what is the way in which order by work and how it will be ordered by based on more then two columns .

menas what is the way to order selected record to order using order by clause with multiple column into order by condition?
Posted

If you provide two or more order by clauses in your query, they will be sorted based on the order of these columns.
For e.g. select * from Table1 order by colA, colB will first sort records by colA and then within the set of same colA records, sort by colB.

Similarly you can define different sort orders for e.g. select * from Table1 order by colA desc, colB asc
 
Share this answer
 
Hi,


Check this...

how to use group by clause into sql server?[^]

Hope this will help you.

Cheers
 
Share this answer
 
consider i have one customer address details tbale with below column

1 cust id
2 cust name
3 city
4 state
5 country


now Iam going to find records by customer name , city and state wise


select * from customer_address_master
order by customer_name , city , state

it will show me

customer wise then find city wise and finally find state wise records

Try it , this wil understand you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900