Загрузка...

COUNT(*) vs COUNT(column) — They're NOT the Same! 🤯

COUNT(*) and COUNT(column) look identical. They're not.
Here's the difference:
🔹 COUNT(*) counts ALL rows — even if values are NULL
🔹 COUNT(column) counts only NON-NULL values
Example:
5 users in a table, but 1 email is NULL.
COUNT(*) returns 5 — counts every row
COUNT(email) returns 4 — NULL doesn't count!
This is why your reports might be showing wrong numbers.
💡 When to use which:
— COUNT(*) for total row count
— COUNT(column) when NULLs matter
💬 Which one do you use more? Drop it in comments!
🔥 SQL Series:
Part 5: COALESCE
Part 6: NULL vs 0
Part 7: COUNT(*) vs COUNT(column) — YOU ARE HERE
Part 8: WHERE vs HAVING
#SQL #Database #Programming #Shorts #SQLTutorial

Видео COUNT(*) vs COUNT(column) — They're NOT the Same! 🤯 канала LogicLayers
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять