nerdexam
Google

PROFESSIONAL-CLOUD-DEVELOPER · Question #44

You have two tables in an ANSI-SQL compliant database with identical columns that you need to quickly combine into a single table, removing duplicate rows from the result set. What should you do?

The correct answer is C. Use the UNION operator in SQL to combine the tables.. The UNION operator in standard SQL combines the result sets of two SELECT statements into a single result set and automatically removes duplicate rows. This is exactly what the question requires: combining two tables with identical columns while deduplicating. Option D, UNION ALL

Implementing data persistence

Question

You have two tables in an ANSI-SQL compliant database with identical columns that you need to quickly combine into a single table, removing duplicate rows from the result set. What should you do?

Options

  • AUse the JOIN operator in SQL to combine the tables.
  • BUse nested WITH statements to combine the tables.
  • CUse the UNION operator in SQL to combine the tables.
  • DUse the UNION ALL operator in SQL to combine the tables.

How the community answered

(33 responses)
  • A
    6% (2)
  • B
    3% (1)
  • C
    88% (29)
  • D
    3% (1)

Explanation

The UNION operator in standard SQL combines the result sets of two SELECT statements into a single result set and automatically removes duplicate rows. This is exactly what the question requires: combining two tables with identical columns while deduplicating. Option D, UNION ALL, also combines result sets but retains all duplicate rows - it does not remove duplicates. Option A, JOIN, combines tables by matching rows on a condition (e.g., a key column); it does not stack rows from two tables vertically. Option B, nested WITH statements (CTEs), is a way to organize queries but is not an operator that combines tables on its own. UNION (C) is the precise ANSI-SQL operator for this task.

Topics

#SQL#UNION operator#Data Manipulation#Deduplication

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVELOPER Practice