0
what is the difference between count(*) and count(column name)?
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.
+ 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
+ 1
the count(*) gave all the table result and count (column name) gave column result