Check sibling questions

Differentiate between count() and count(*) functions in SQL with appropriate example.

 

Answer:

COUNT( )

COUNT(*)

Always used with a column name passed as argument and returns the count of the number of rows with non-null values in the column given as argument.

Returns the count of all rows in the table.

 

Example:

  • COUNT(*) returns 5 since there are 5 records in the table DEPARTMENT.
  • COUNT(DEPT_NAME) return 4 since there is 1 null value in the column DEPT_NAME.
  1. Computer Science - Class 12
  2. Solutions to CBSE Sample Paper - Computer Science Class 12

About the Author

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo