With SQL, how can you return the number of records in the "Persons" table?
-
SELECT COLUMNS() FROM Persons
-
SELECT COUNT(*) FROM Persons
-
SELECT COLUMNS(*) FROM Persons
-
SELECT COUNT() FROM Persons
COUNT(*) is the aggregate function that returns the total number of rows in a table. COLUMNS is not a valid SQL function for counting.
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.