COUNT, DISTINCT, and NULLs in SQL Server

preview_player
Показать описание
NULLs are interesting values. While they fill an important need in the database, it's not always intuitive how different SQL Server statements and functions handle them.

This week we examine how COUNTs and DISTINCTs interact with NULLs...and how they may not always be doing what you expect with them.

Related blog post with more examples:

Follow me on Twitter:
Рекомендации по теме
Комментарии
Автор

How about doing the count distinct with a + case when exists (select * from ... where col1 is null) then 1 else 0 end?

Sttuey
Автор

Hola, qué hacer si la extracción de la tabla de la base de datos es en tuplas y estos comandos no funcionan? Hay forma de evitar que las tablas se extraigan en tuplas en sql?

nohemialvarez
Автор

select distinct(email_subject) as cnt_sub
from lemonemails

mercypaul