Difficulty: Easy
Correct Answer: SELECT DISTINCT
Explanation:
Introduction / Context: When retrieving data, you may encounter duplicates due to joins, denormalization, or repeated values in a column set. SQL provides a standard way to collapse duplicates so that each unique combination of selected columns appears only once in the result set.
Given Data / Assumptions:
Concept / Approach: The DISTINCT keyword is defined by the SQL standard to eliminate duplicate rows from the projection. Some vendors historically accepted UNIQUE as a synonym, but it is not universally portable. There is no standard DIFFERENT keyword for this purpose.
Step-by-Step Solution:
Identify need: collapse duplicate rows across the selected columns. Recall the standard syntax: SELECT DISTINCT col_list FROM table ... Prefer portable, standard SQL over vendor-specific synonyms. Choose SELECT DISTINCT.Verification / Alternative check: SQL references for major systems (PostgreSQL, SQL Server, MySQL, Oracle) document DISTINCT as the standard duplicate-elimination modifier in SELECT.
Why Other Options Are Wrong:
Common Pitfalls: Overusing DISTINCT to mask poor joins; DISTINCT adds sorting/aggregation overhead. Consider proper join conditions and indexes before relying on DISTINCT for performance-sensitive queries.
Final Answer: SELECT DISTINCT
Discussion & Comments