|
INTERVIEW QUESTIONS
DATABASE
MS SQL SERVER
DETAILS
Question: Can the Query Output Be Sorted by Multiple Columns in MS SQL Server?
Answer: You can specifying multiple columns in the ORDER BY clause as shown in the following example statement, which returns rows sorted by "tag" and "counts" values:
SELECT tag, counts, url, created FROM ggl_links ORDER BY tag, counts GO
tab counts url created
DBA 390 www.mysql.com 2006-01-01
DBA 960 www.oracle.com 2005-01-01
DBA 972 globalguideline.com 2007-05-19
DEV 120 globalguideline.com/xml 2006-04-30
DEV 439 www.php.net 2004-01-01
SQA 728 globalguideline.com/sql 2007-05-19
SQA 828 www.winrunner.com 2003-01-01
|
|
|
Category |
MS SQL Server Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9318 users |
Added on |
9/23/2014 |
Views |
71075 |
Rate it! |
|
|
Question:
Can the Query Output Be Sorted by Multiple Columns in MS SQL Server?
Answer:
You can specifying multiple columns in the ORDER BY clause as shown in the following example statement, which returns rows sorted by "tag" and "counts" values:
SELECT tag, counts, url, created FROM ggl_links ORDER BY tag, counts GO
tab counts url created
DBA 390 www.mysql.com 2006-01-01
DBA 960 www.oracle.com 2005-01-01
DBA 972 globalguideline.com 2007-05-19
DEV 120 globalguideline.com/xml 2006-04-30
DEV 439 www.php.net 2004-01-01
SQA 728 globalguideline.com/sql 2007-05-19
SQA 828 www.winrunner.com 2003-01-01 Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How To Sort the Query Output with ORDER BY Clauses in MS SQL Server?
|
View Answer
|
|
How To Add More Data to the Testing Table in MS SQL Server?
|
View Answer
|
|
How To Select Some Specific Rows from a Table in MS SQL Server?
|
View Answer
|
|
How To Select Some Specific Columns from a Table in a Query in MS SQL Server?
|
View Answer
|
|
How To Select All Columns of All Rows from a Table with a SELECT statement in MS SQL Server?
|
View Answer
|
|
What Is a SELECT Query Statement in MS SQL Server?
|
View Answer
|
|
How To Use ORDER BY with UNION Operators in MS SQL Server?
|
View Answer
|
|
How To Use UNION to Merge Outputs from Two Queries Together in MS SQL Server?
|
View Answer
|
|
How To Return the Second 5 Rows in MS SQL Server?
|
View Answer
|
|
How To Return the Top 5 Rows from a SELECT Query in MS SQL Server?
|
View Answer
|
|
How To Count Groups Returned with the GROUP BY Clause in MS SQL Server?
|
View Answer
|
|
How To Use Subqueries in the FROM Clause in MS SQL Server?
|
View Answer
|
|
How To Use Subqueries with the EXISTS Operators in MS SQL Server?
|
View Answer
|
|
How To Use Subqueries with the IN Operators in MS SQL Server?
|
View Answer
|
|
What Is a Subquery in a SELECT Query Statement in MS SQL Server?
|
View Answer
|
|
How To Write an Inner Join with the WHERE Clause in MS SQL Server?
|
View Answer
|
|
How To Write a Query with a Full Outer Join in MS SQL Server?
|
View Answer
|
|
How To Write a Query with a Right Outer Join in MS SQL Server?
|
View Answer
|
|
How To Write a Query with a Left Outer Join in MS SQL Server?
|
View Answer
|
|
How To Define and Use Table Alias Names in MS SQL Server?
|
View Answer
|