SQL COUNT(*) vs COUNT(column): The NULL Difference
By Sharon Ben-Moshe · August 16, 2026 · 1 min read
Sharon Ben-Moshe is the founder of sqlfmt, a browser-based SQL formatter and validator with misspelled-keyword suggestions across PostgreSQL, MySQL, SQLite, SQL Server, and BigQuery.
COUNT(*) counts rows; COUNT(column) skips NULLs. See the exact difference, join behavior, COUNT(DISTINCT), and reliable SQL examples.
Quick answer
Use COUNT(*) when you need every result row. Use COUNT(column) when you need only rows where that expression is not NULL. The two counts match only when the expression cannot be NULL; COUNT(DISTINCT column) additionally removes duplicate non-NULL values.
Keep reading
BigQuery QUALIFY Clause: Filter Window Functions Directly
By Sharon Ben-Moshe · Aug 16, 2026
Use BigQuery QUALIFY to filter window-function results without an outer subquery. Learn evaluation order, top-N-per-group patterns, and portability.
Read postSQL Window Functions vs GROUP BY: Keep Detail Rows
By Sharon Ben-Moshe · Aug 16, 2026
GROUP BY collapses rows; window functions retain detail and add calculations beside it. See when each approach fits, with clear SQL examples.
Read postTry it now
Paste your SQL into sqlfmt — format, validate, and catch typos free in your browser.