Think Like a Data Analyst

🔍 SQL Tip: What's the Difference Between COUNT(*) and COUNT(1)? 🧮

If you're curious about how COUNT(*) differs from COUNT(1), here's a quick breakdown using emojis:

1️⃣ Basic Count

COUNT(*) ➡️ 🧮 Counts all rows in a table.
COUNT(1) ➡️ 🧮 Also counts all rows by evaluating a constant.
2️⃣ Nulls

Both COUNT(*) and COUNT(1) ➡️ ❓✅ Include rows with NULL values.
3️⃣ Columns Involved

COUNT(*) ➡️ 📦 Doesn’t check any specific column, just counts rows.
COUNT(1) ➡️ 🧩 Similarly, evaluates the constant 1 for row count.
4️⃣ Performance

⚡ Both are optimized and perform equally in most databases!
5️⃣ Practical Difference

Both are used to count rows, but COUNT(*) is more commonly seen in SQL queries. 🎯
In most scenarios, they function the same – just a difference in syntax!

1 year ago | [YT] | 1