What is the difference between UNION and UNION ALL?
Experience Level: Medior
Tags: DatabasesSQL
Answer
UNION returns distinct rows, UNION ALL returns all rows. Because it doesn't need to find unique rows, it is faster.
Related Databases job interview questions
Describe and tell the difference amongst table, view and materialized view.
Databases MediorCan you use different column names for tables merged using UNION ALL? What will be the column names in the result?
DatabasesSQL MediorWhat is the processing order of logical parts of the following query?
DatabasesSQL MediorWhen you use SQL Server, what is a difference between local and global temporary table?
DatabasesMS SQL ServerSQL SeniorWhat is a result of the query below for table with 10 rows when there are 2 clients with the headcount column having a NULL value, there are 7 customers with 1 head and 1 customer with 2 heads?
DatabasesSQL Medior