adspace


How to use order by with union operators in ms sql server?

Answer Posted / Idreesh Ahmed

To use the ORDER BY clause with the UNION operator in MS SQL Server, you can combine multiple SELECT statements with UNION and place the ORDER BY at the end of the query:n`(SELECT column1, column2 FROM table1 WHERE condition1) UNION (SELECT column1, column2 FROM table2 WHERE condition2) ORDER BY column1, column2`

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different SQL Server Versions you have worked on?

1079


What are the kinds of subquery?

1107


Can we shrink data file in sql server?

1128


What are the different types of subquery?

1235


What are different types of constraints?

1001


You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?

1213


Equi join and non equi join is possible with sql server?

1134


What is temporary table in sql server? Why we use temp table?

1021


Disadvantages of the indexes?

1223


What is a view in sql?

1040


List the ways in which dynamic sql can be executed?

1086


Can one drop a column from a table?

1089


Is it possible to have clustered index on separate drive from original table location?

1040


Explain system functions or built-in functions? What are different types of system functions?

1065


What is clustered index

1086