𝗧𝘄𝗼 𝗦𝗤𝗟 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀. 𝗢𝗻𝗲 𝘀𝗺𝗮𝗹𝗹 𝗱𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲. 𝗕𝘂𝘁 𝗶𝘁 𝗰𝗮𝗻 𝗰𝗵𝗮𝗻𝗴𝗲 𝘆𝗼𝘂𝗿 𝗿𝗲𝘀𝘂𝗹𝘁𝘀 𝗰𝗼𝗺𝗽𝗹𝗲𝘁𝗲𝗹𝘆. After finishing my 21 Days of SQL challenge, I decided to continue sharing small SQL insights that are easy to miss but important to understand. Today’s tip 👇 COUNT(*) vs COUNT(column) At first glance, these two look almost the same. But they behave very differently when NULL values are present. COUNT(*) Counts every row in the table, regardless of NULL values. SELECT COUNT(*) FROM orders; COUNT(column) Counts only rows where the specified column is NOT NULL. SELECT COUNT(discount) FROM orders; So if the discount column contains NULL values, those rows will not be counted. 💡 Why this matters In real datasets, NULL values are very common. Using the wrong count method can lead to incorrect analysis and misleading results. Key takeaway COUNT(*) → counts rows COUNT(column) → counts non-NULL values Small SQL details like this make a big difference in data analysis. Curious to know 👇 Did you know this difference before, or did it surprise you? #SQL #DataAnalytics #LearningInPublic #SQLTips #DataAnalyticsJourney
Informative post
Small difference, but huge impact on results. Null handling really matters