Multiple choice sql

With SQL, how can you return the number of records in the "Persons" table?

  1. SELECT COLUMNS() FROM Persons

  2. SELECT COUNT(*) FROM Persons

  3. SELECT COLUMNS(*) FROM Persons

  4. SELECT COUNT() FROM Persons

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

COUNT(*) is the aggregate function that returns the total number of rows in a table. COLUMNS is not a valid SQL function for counting.

AI explanation

SELECT COUNT(*) FROM Persons is standard SQL syntax that returns the total number of rows in the Persons table, using the built-in aggregate function COUNT() with the wildcard * to count all rows regardless of NULLs in any column. The other options are invalid SQL: COLUMNS() is not a real SQL function (it doesn't count rows), and COUNT() without any argument (not even *) is a syntax error since COUNT requires an argument. Only COUNT(*) or COUNT(column_name) are valid forms, making the second option the only syntactically and semantically correct choice.