With SQL, how can you return the number of records in the "Persons" table?
2017
With SQL, how can you return the number of records in the "Persons" table?
- A.
SELECT COUNT (*) FROM Persons
- B.
SELECT COUNT () FROM Persons
- C.
SELECT COUNT (** ) FROM Persons
- D.
SELECT COLUMN (+) FROM Persons
Attempted by 2035 students.
Show answer & explanation
Correct answer: A
Correct query: SELECT COUNT(*) FROM Persons; COUNT(*) counts all rows in the table, including rows where column values are NULL.
COUNT(column_name) counts only the non-NULL values in that column.
Forms like empty parentheses, COUNT(**), or using COLUMN(+) are invalid for counting rows; use COUNT(*) instead.
A video solution is available for this question — log in and enroll to watch it.