Recall & Review
beginner
What does combining result sets in SQL allow you to do?
It allows you to merge data from multiple queries into a single list, making it easier to analyze or report on related information from different tables or queries.
Click to reveal answer
beginner
Name two common SQL commands used to combine result sets.
UNION and UNION ALL are commonly used to combine result sets from two or more SELECT queries.
Click to reveal answer
intermediate
Why might you choose UNION ALL over UNION when combining result sets?
UNION ALL includes all rows from the combined queries, including duplicates, which can be faster because it skips the step of removing duplicates.
Click to reveal answer
beginner
How can combining result sets help in real-life business reporting?
It helps by bringing together data from different departments or sources into one report, like combining sales from different regions to see total company sales.
Click to reveal answer
intermediate
What must be true about the columns in the SELECT statements when combining result sets with UNION?
Each SELECT must have the same number of columns, and the columns must have compatible data types to combine correctly.
Click to reveal answer
Which SQL command combines result sets and removes duplicate rows?
✗ Incorrect
UNION combines result sets and removes duplicates, while UNION ALL includes duplicates.
What happens if the SELECT statements have different numbers of columns when using UNION?
✗ Incorrect
UNION requires the same number of columns in each SELECT; otherwise, it causes an error.
Why is combining result sets useful in databases?
✗ Incorrect
Combining result sets merges data from different queries for easier analysis.
Which command includes all rows, even duplicates, when combining result sets?
✗ Incorrect
UNION ALL includes all rows, duplicates included.
In a business context, combining result sets helps to:
✗ Incorrect
Combining result sets helps create comprehensive reports by merging data from various sources.
Explain why combining result sets is useful when working with data from multiple tables or queries.
Think about how you might want to see all related information together.
You got /3 concepts.
Describe the difference between UNION and UNION ALL when combining result sets.
Consider what happens to repeated rows.
You got /3 concepts.