I was recently asked this question in an interview. I tried this in mySQL, and got the same results(final results). All gave the number of rows in that particular table. Can
COUNT(*)
will count the number of rows, while COUNT(expression)
will count non-null values in expression and COUNT(column)
will count all non-null values in column.
Since both 0 and 1 are non-null values, COUNT(0)=COUNT(1)
and they both will be equivalent to the number of rows COUNT(*)
. It's a different concept, but the result will be the same.