Which SQL statement is used to return only different values?

  1. SELECT DISTINCT

  2. SELECT DIFFERENT

  3. SELECT UNIQUE

  4. SELECT ALL


Correct Option: A

AI Explanation

To answer this question, you need to understand how to filter and retrieve distinct values in a SQL query.

Let's go through each option to understand why it is correct or incorrect:

Option A) SELECT DISTINCT - This option is correct because the "DISTINCT" keyword is used in a SQL SELECT statement to retrieve only unique or different values. It eliminates duplicate rows from the result set.

Option B) SELECT DIFFERENT - This option is incorrect because there is no keyword "DIFFERENT" in SQL that can be used to retrieve distinct values.

Option C) SELECT UNIQUE - This option is incorrect because the "UNIQUE" keyword is not used in SQL to retrieve distinct values. It is used to define a column or set of columns as unique constraints, ensuring that no duplicate values are entered into those columns.

Option D) SELECT ALL - This option is incorrect because the "ALL" keyword is the default behavior in SQL. It is not used to retrieve distinct values. When you use the "SELECT" statement without specifying DISTINCT, it returns all rows, including duplicates.

The correct answer is Option A) SELECT DISTINCT. This option is correct because it is the correct SQL statement to retrieve only different values, eliminating duplicates from the result set.

Find more quizzes: