↔️ ↕️


one thing that I see fairly often and

occasionally am guilty of doing myself

is using count distinct and distinct

interchangeably to see the unique values

in a column of data the question is

though are they really interchangeable

so let's start with this table of data

you'll notice that there are some

duplicate values in column one this is

going to be really important for seeing

how the following queries work so let's

say we have count distinct from column

one from our test table and you'll

notice the query returns a count of two

unique values that's great if we want to

see what those values are maybe we just

get rid of the count and say select

distinct from column one and that should

return all the unique values in that

column the interesting thing here is

though instead of getting just two rows

Related queries:

how to count not null columns in sql
how to not include null values in sql query
is not null sql example
how to not null in sql
is null counted in sql
how to not get null values in sql