0

what is the difference between count(*) and count(column name)?

15th Jan 2017, 5:54 AM
Gayatri Sridhar
Gayatri Sridhar - avatar
3 Answers
+ 6
count(*) used to know how many rows exists in your table, at least one column have value, hence with count(column name) command if some row have null value in this column then not gonna be counted.
17th Jan 2017, 4:33 AM
Jahndev
Jahndev - avatar
+ 3
Maybe this can explain it better: Lets say we have a table named Employees with 10 records. Of these 5 records have a null value for Terminated. 1. Select count(*) from Employees ; -- this will yield 10 as the value as long as there is at least one value not null in the record entry. 2. Select count(Terminated) from Employees ; -- this will only yield the sum of those records without a NULL value for Terminated hence 5
16th Jan 2017, 7:38 PM
Ben Rivera
+ 1
the count(*) gave all the table result and count (column name) gave column result
15th Jan 2017, 6:57 AM
Abhishek Shukla
Abhishek Shukla - avatar