What is the differences b/w
select count(*) from tablename
select count(colname) from tablename
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Feb 27, 2011, 12:24 PM
Guest UserPosted Feb 24, 2011, 3:22 PM
count(colname) will include duplicates.
count(distinct colname) will filter out duplicates.
Syed ShakeerPosted Feb 24, 2011, 1:02 PM
You had ask a good question.See the below example
Name Rollno
Hussain null
Hussain null
NULL 101
NULL 102
select count(*) from tableName
result: 4 Rows
select count(Rollno) from tablename
result: 2 Rows
Guest UserPosted Feb 24, 2011, 10:26 AM
When you specify a column name, the count will not include nulls or duplicate values.