With SQL, how can you return all the records from a table named "Persons" sorted descending by "FirstName"?

  1. SELECT * FROM Persons ORDER FirstName DESC

  2. SELECT * FROM Persons SORT BY 'FirstName' DESC

  3. SELECT * FROM Persons ORDER BY FirstName DESC

  4. SELECT * FROM Persons SORT 'FirstName' DESC


Correct Option: C

AI Explanation

To return all the records from a table named "Persons" sorted descending by "FirstName" in SQL, you can use the following query:

C. SELECT * FROM Persons ORDER BY FirstName DESC

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

Option A) SELECT * FROM Persons ORDER FirstName DESC This option is incorrect because the correct syntax is to use the keyword "BY" after "ORDER" to specify the column to sort by. So, it should be "ORDER BY" instead of just "ORDER".

Option B) SELECT * FROM Persons SORT BY 'FirstName' DESC This option is incorrect because the correct syntax is to use "ORDER BY" instead of "SORT BY" to specify the sorting order.

Option C) SELECT * FROM Persons ORDER BY FirstName DESC This option is correct because it uses the correct syntax to sort the records in descending order based on the "FirstName" column. The keyword "ORDER BY" is used to specify the sorting order, and "DESC" is used to indicate descending order.

Option D) SELECT * FROM Persons SORT 'FirstName' DESC This option is incorrect because there is no "SORT" keyword in SQL. The correct keyword to use for sorting is "ORDER BY".

The correct answer is C. SELECT * FROM Persons ORDER BY FirstName DESC. This option is correct because it uses the correct syntax to sort the records in descending order based on the "FirstName" column.

Find more quizzes: