What is the differences b/w
select count(*) from tablename
select count(colname) from tablename
Records counts
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Guest UserRank #1,422 · 1.2K reputationPosted Feb 24, 2011, 5:26 AM EST
When you specify a column name, the count will not include nulls or duplicate values.
Syed ShakeerRank #777 · 3K reputationPosted Feb 24, 2011, 8:02 AM EST
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 UserRank #1,422 · 1.2K reputationPosted Feb 24, 2011, 10:22 AM EST
count(colname) will include duplicates.
count(distinct colname) will filter out duplicates.
Suthish NairRank #92 · 22.8K reputationPosted Feb 27, 2011, 7:24 AM EST