What is ORDER BY statement used for in Microsoft SQL server?
Experience Level: Junior
Tags: DatabasesMS SQL ServerQuality Assurance (QA)
Answer
ORDER BY statement is used together with SELECT statement and defines by which columns the result-set is sorted.
The following query will sort the result-set by LastName and FirstName.
SELECT * FROM Customers ORDER BY LastName, FirstName
Related Databases job interview questions
What is the difference between temp tables and table variables in SQL?
DatabasesMS SQL ServerSQL SeniorWhat is the meaning of ASC and DESC keywords in SQL server?
DatabasesQuality Assurance (QA) JuniorWhat is WHERE statement good for in SQL server script?
DatabasesMS SQL ServerQuality Assurance (QA) JuniorWhat is DISTINCT and what is good for?
DatabasesMS SQL ServerQuality Assurance (QA) JuniorWhat is TOP and what is it good for in SQL server script?
DatabasesQuality Assurance (QA) Junior