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



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

Answer / 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

More SQL Server Interview Questions

What is normalization and what are the different forms of normalizations?

2 Answers  


Can a table have 2 primary keys?

1 Answers  


What is normalization and its types?

1 Answers  


Explain how to use linked server?

1 Answers  


What is dknf in normalization form?

1 Answers  


What is a table called, if it does not have neither Cluster nor Non-cluster Index?

2 Answers  


what is an extended stored procedure? Can you instantiate a com object by using t-sql? : Sql server database administration

1 Answers  


What are the 3 types of schema?

1 Answers  


How will you add a dimension to cube? : sql server analysis services, ssas

1 Answers  


What is sql collation?

1 Answers  


what are default? Is there a column to which a default cant be bound?

1 Answers  


what are questions asked in TCS for database tester (sqlserver)for 2-3 exp?

1 Answers   ABC, TCS,


Categories