Which of the following statement(s) is/are correct regarding COUNT functions…
2021
Which of the following statement(s) is/are correct regarding COUNT functions in Structured Query Language of Relational Database Management System? I. COUNT(* ) is used to count the number of values in a column. II. COUNT() is used to count the number of rows of the query result.
- A.
Only I
- B.
Only II
- C.
Both I and II
- D.
Neither I nor II
Attempted by 1945 students.
Show answer & explanation
Correct answer: D
Statement Analysis:
I. COUNT(*) is used to count the number of values in a column.
Incorrect
COUNT(*) counts the total number of rows in the query result, including rows containing NULL values.
Correct example:
SELECT COUNT(*) FROM STUDENT;
II. COUNT() is used to count the number of rows of the query result.
Incorrect
COUNT() without any argument is invalid in SQL.
Correct formats:
COUNT(*)
COUNT(column_name)
Example:
SELECT COUNT(MARKS) FROM STUDENT;
Therefore, both statements are incorrect.