Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

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:

Question 25 Example 1 -Teachoo.png

COUNT DEPT NAME return 4 -Teachoo.png

COUNT DEPT NAME return 5 -Teachoo.png

  • 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.
Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

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, Social Science, Physics, Chemistry, Computer Science at Teachoo.