With SQL, how can you return the number of records in the "Persons" table?
-
SELECT COUNT(*) FROM Persons
-
SELECT COLUMNS(*) FROM Persons
-
SELECT COLUMNS() FROM Persons
-
SELECT COUNT() FROM Persons
Reveal answer
Fill a bubble to check yourself
A
Correct answer
Explanation
SQL uses the COUNT aggregate function to return the number of records. Option A correctly uses COUNT(*) which counts all rows including nulls. Options B and C use COLUMNS which is not a valid SQL function, and Option D uses COUNT() without * which is incomplete syntax in most SQL implementations.
AI explanation
SELECT COUNT(*) FROM Persons returns the total number of rows in the table, since COUNT(*) is the standard SQL aggregate function for counting rows. COLUMNS(*) and COUNT() with no argument are not valid SQL constructs.