In SQL, what's the difference between count(column) and count(*)?

Posted by Bill the Lizard on Stack Overflow See other posts from Stack Overflow or by Bill the Lizard
Published on 2008-09-12T15:27:17Z Indexed on 2010/05/05 9:38 UTC
Read the original article Hit count: 319

Filed under:

I have the following query:

select column_name, count(column_name)
from table
group by column_name
having count(column_name) > 1;

What would be the difference if I replaced all calls to count(column_name) to count(*)?

This question was inspired by a previous one.


Edit:

To clarify the accepted answer (and maybe my question), using count(*) in this case returns an extra row in the result that contains a null and the count of null values in the column.

© Stack Overflow or respective owner

Related posts about sql