204k views
3 votes
In regards to sorting, if a DISTINCT option is used in the SELECT clause of a query then ____.​

A) Sorting is not allowed
B) Sorting is mandatory
C) Sorting is dependent on the database
D) Sorting order is undefined

1 Answer

7 votes

Final answer:

Using the DISTINCT option in a SELECT clause removes duplicates but does not determine sort order; an ORDER BY clause must be used for sorting.

Step-by-step explanation:

When a DISTINCT option is used in the SELECT clause of a SQL query, the sorting of the results is not inherently affected. The DISTINCT keyword is used to remove duplicate records and return only unique values in the result set. However, the order in which the unique results are presented is not determined by the DISTINCT clause. If you want to sort the results, you should use the ORDER BY clause explicitly in your SQL statement. So, the correct answer to the question is D) Sorting order is undefined unless explicitly specified with an ORDER BY clause.

User NielMalhotra
by
8.3k points