Microsoft SQL Server Database Quiz Questions

Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:UNION and UNION ALL
Current Quiz Count:45
Progress
0%
Q1
True / False

The UNION keyword combines results from multiple SELECT statements and removes duplicate rows by default.

Q2
True / False

UNION ALL will return only unique rows from the combined SELECT statements.

Q3
True / False

Using UNION requires that all SELECT statements have the same number of columns with compatible data types.

Q4
True / False

UNION ALL is more performant than UNION because it does not remove duplicate rows.

Q5
True / False

The number of columns in each SELECT statement is not important when using UNION.

Q6
True / False

UNION ALL can be used to combine results from SELECT statements with different column names.

Q7
True / False

In a UNION ALL operation, if one of the SELECT statements has a WHERE clause, it will not affect the other SELECT statements.

Q8
True / False

Using UNION ALL with large datasets might result in performance issues due to duplicate rows being included.

Q9
True / False

UNION and UNION ALL are both set operations that can be used to combine the results of multiple SELECT queries.

Q10
True / False

UNION cannot be used if the SELECT statements have different numbers of columns.

Q11
True / False

The ORDER BY clause in a UNION query affects only the final result set, not the individual SELECT statements.

Q12
True / False

UNION ALL will return rows in the order they appear in the SELECT statements, without sorting them.

Q13
True / False

Using UNION ALL between two queries with different column names will result in an error.

Q14
True / False

UNION ALL is less efficient than UNION when dealing with large datasets due to the additional processing required to remove duplicates.

Q15
True / False

You can use UNION ALL to combine result sets from SELECT statements with different column names as long as the data types match.

Q16
Single Choice

Which SQL keyword is used to combine the results of two or more SELECT statements while removing duplicates?

Q17
Single Choice

What does UNION ALL do with duplicate rows from the SELECT statements?

Q18
Single Choice

When using UNION, how are the columns from each SELECT statement combined?

Q19
Single Choice

Which of the following will be included in the result set of a UNION query?

Q20
Single Choice

Which SQL keyword will not remove duplicates from the combined result set?

Q21
Single Choice

In a query with UNION, how can you ensure the results are sorted?

Q22
Single Choice

Can UNION be used to combine result sets from SELECT statements with different numbers of columns?

Q23
Single Choice

What is a potential drawback of using UNION ALL with large datasets?

Q24
Single Choice

Which of the following is true about the use of UNION in SQL queries?

Q25
Single Choice

In a UNION ALL operation, what happens if one SELECT statement includes a WHERE clause and another does not?

Q26
Single Choice

What will be the output of the following query? `SELECT Col1 FROM TableA UNION SELECT Col1 FROM TableB;`

Q27
Single Choice

What is a common use case for UNION ALL in SQL queries?

Q28
Single Choice

Which of the following queries will not work if the number of columns in each SELECT statement differs?

Q29
Single Choice

How can you ensure that a UNION query returns results in a specific order?

Q30
Single Choice

What happens if you apply an ORDER BY clause within a UNION ALL query?

Q31
Multiple Choice

Which of the following code snippets correctly uses UNION to combine results from two SELECT statements?

SQL Code
SELECT Col1 FROM TableA
UNION
SELECT Col1 FROM TableB;
Q32
Multiple Choice

Which SQL keyword can be used to combine results from multiple SELECT statements, including duplicates?

SQL Code
SELECT Col1 FROM TableA
UNION ALL
SELECT Col1 FROM TableB;
Q33
Multiple Choice

What is the correct way to use UNION ALL in SQL to combine results from three different tables?

SQL Code
SELECT Col1 FROM TableA
UNION ALL
SELECT Col1 FROM TableB
UNION ALL
SELECT Col1 FROM TableC;
Q34
Multiple Choice

Which code snippet will include all rows from the SELECT statements, including duplicates?

SQL Code
SELECT Col1 FROM TableA
UNION ALL
SELECT Col1 FROM TableB;
Q35
Multiple Choice

Which of the following is a valid application of the UNION keyword?

SQL Code
SELECT Col1 FROM TableA
UNION
SELECT Col1 FROM TableB;
Q36
Multiple Choice

Which SQL operation would you use to find common rows between two SELECT statements?

SQL Code
SELECT Col1 FROM TableA
INTERSECT
SELECT Col1 FROM TableB;
Q37
Multiple Choice

What is the effect of applying the EXCEPT keyword between two SELECT statements?

SQL Code
SELECT Col1 FROM TableA
EXCEPT
SELECT Col1 FROM TableB;
Q38
Multiple Choice

Which of the following operations combines results from multiple queries and eliminates duplicates, but is different from UNION?

Q39
Multiple Choice

How does the result set of UNION differ from UNION ALL when combining results from multiple SELECT statements?

Q40
Multiple Choice

What is the result of the following query? `SELECT Col1 FROM TableA UNION ALL SELECT Col1 FROM TableB WHERE Col1 > 100;`

SQL Code
SELECT Col1 FROM TableA
UNION ALL
SELECT Col1 FROM TableB
WHERE Col1 > 100;
Q41
Multiple Choice

Which SQL operation would you use to return rows that are present in one SELECT statement but not in another?

SQL Code
SELECT Col1 FROM TableA
EXCEPT
SELECT Col1 FROM TableB;
Q42
Multiple Choice

How can you combine result sets from different tables with the same column names but different column data types using UNION?

Q43
Multiple Choice

What will be the result of the following query? SELECT Col1 FROM TableA UNION SELECT Col1 FROM TableB UNION ALL SELECT Col1 FROM TableC;

SQL Code
SELECT Col1 FROM TableA
UNION
SELECT Col1 FROM TableB
UNION ALL
SELECT Col1 FROM TableC;
Q44
Multiple Choice

Which of the following code snippets uses UNION to combine result sets and ensure that only unique rows are returned?

SQL Code
SELECT Col1 FROM TableA
UNION
SELECT Col1 FROM TableB;
Q45
Multiple Choice

What will be the result of this query? SELECT Col1 FROM TableA UNION SELECT Col1 FROM TableB UNION ALL SELECT Col1 FROM TableC WHERE Col1 NOT IN (SELECT Col1 FROM TableA);

SQL Code
SELECT Col1 FROM TableA
UNION
SELECT Col1 FROM TableB
UNION ALL
SELECT Col1 FROM TableC
WHERE Col1 NOT IN (SELECT Col1 FROM TableA);