- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Same Table, Same Filter, DIFFERENT COUNT?! (COUNT(*) vs COUNT(column))
Same table, same filter, but different counts?! In this SQL tutorial, we see why COUNT(*), COUNT(bonus) and COUNT(1) can give different results, and how NULL values change what the COUNT function really does.
Your manager asks: “How many customers got a bonus?”
You run one SQL query and get 100.
You tweak just one part of the COUNT function and now you get 60.
Same table. Same filter. Different count.
In this video, using a simple Employees table, we break down the difference between:
COUNT(*)
COUNT(column) (like COUNT(bonus))
COUNT(1)
…and understand why they don’t always behave the way we think.
What you’ll learn in this video:
How COUNT(*) answers: “How many rows do I have?” (counts all rows in the result)
How COUNT(column) counts only rows where that column is NOT NULL
Why COUNT(bonus) can be smaller than COUNT(*) on the same table
How COUNT(1) usually behaves like COUNT(*) in modern databases
A simple mental model to never get confused by COUNT again in reports or interviews
We’ll walk through:
Building a small Employees table with some NULL bonus values
Running COUNT(*), COUNT(bonus), and COUNT(1) on that data
A grouped example by city to show totals vs “has bonus” counts
An interview-style question: “COUNT(*) = 100 but COUNT(col) = 60 – why?”
This video is for:
SQL beginners who keep getting unexpected counts
Data analysts and data engineers preparing for interviews
Anyone confused about COUNT, NULL, and what’s actually being counted in their queries
If this helped you, subscribe to SQLWithAsif for more SQL traps, interview questions, and practical examples that make you job-ready.
Also check out my previous video on NOT IN vs NOT EXISTS – another classic SQL trap where a query returns 0 rows because of NULL.
#sql #sqltutorial #sqlforbeginners #sqlcount #countstar #count1 #sqlnull #dataanalytics
Видео Same Table, Same Filter, DIFFERENT COUNT?! (COUNT(*) vs COUNT(column)) канала SQLWithAsif
Your manager asks: “How many customers got a bonus?”
You run one SQL query and get 100.
You tweak just one part of the COUNT function and now you get 60.
Same table. Same filter. Different count.
In this video, using a simple Employees table, we break down the difference between:
COUNT(*)
COUNT(column) (like COUNT(bonus))
COUNT(1)
…and understand why they don’t always behave the way we think.
What you’ll learn in this video:
How COUNT(*) answers: “How many rows do I have?” (counts all rows in the result)
How COUNT(column) counts only rows where that column is NOT NULL
Why COUNT(bonus) can be smaller than COUNT(*) on the same table
How COUNT(1) usually behaves like COUNT(*) in modern databases
A simple mental model to never get confused by COUNT again in reports or interviews
We’ll walk through:
Building a small Employees table with some NULL bonus values
Running COUNT(*), COUNT(bonus), and COUNT(1) on that data
A grouped example by city to show totals vs “has bonus” counts
An interview-style question: “COUNT(*) = 100 but COUNT(col) = 60 – why?”
This video is for:
SQL beginners who keep getting unexpected counts
Data analysts and data engineers preparing for interviews
Anyone confused about COUNT, NULL, and what’s actually being counted in their queries
If this helped you, subscribe to SQLWithAsif for more SQL traps, interview questions, and practical examples that make you job-ready.
Also check out my previous video on NOT IN vs NOT EXISTS – another classic SQL trap where a query returns 0 rows because of NULL.
#sql #sqltutorial #sqlforbeginners #sqlcount #countstar #count1 #sqlnull #dataanalytics
Видео Same Table, Same Filter, DIFFERENT COUNT?! (COUNT(*) vs COUNT(column)) канала SQLWithAsif
Комментарии отсутствуют
Информация о видео
15 декабря 2025 г. 15:11:32
00:12:43
Другие видео канала














