RSS Feed

Multiple Choice Questions on SQL Union

Multiple Choice Questions on SQL Union

1) What does UNION operator do in a SQL Server statement?

a) Bring common data from the listed tables.
b) Bring data which is not common from the listed tables.
c) Bring all data from the listed tables.
d) Bring all distinct from the listed tables.

2) Which one is correct syntax for applying UNION operator?

a) SELECT column_name(s) FROM table_name1 UNION table_name2
b) SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
c) UNION SELECT column_name(s) FROM table_name1
SELECT column_name(s) FROM table_name2
d) SELECT FROM table_name1 AND table_name2

3) How can we get all records (redundant as well as non-redundant) from union operator?

a) Using ‘ALL’ operator with UNION.
b) Using ‘Distinct’ operator with UNION.
c) We get all records (redundant as well as non-redundant) with UNION operator by default.
d) None of the above.

4) The column names in the result of a UNION (of tables) are always equal to the column names in the 1st SELECT statement with the UNION operator, true or false?

a) True
b) False

5) Is UNION or UNION ALL operator valid for LONG data type column?

a) True
b) False

6) Can we use UNION operator in SELECT statement which contains TABLE collection expressions?

a) True
b) False

7) UNION operator requires an extra overhead of removing redundant rows, is it true?

a) True
b) False

8) What is true about order by with Union operator?

a) Order By can be issued in each result set.
b) It can be issued for the overall result set.
c) Both A & B.
d) None of the above

9) The result set will have Column names from the first query, correct?

a) True
b) False

10) If we know the records returned by our query are unique then which operator will be preferred out of UNION or UNION ALL?

a) Union
b) Union ALL


Answers