DISTINCT question

Here is a code from an exercise:

SELECT DISTINCT b.browse_date,


c.user_id IS NOT NULL AS ‘is_checkout’,

p.user_id IS NOT NULL AS ‘is_purchase’

FROM browse AS ‘b’

LEFT JOIN checkout AS ‘c’

ON c.user_id = b.user_id

LEFT JOIN purchase AS ‘p’

ON p.user_id = b.user_id


My question is simple - does DISTINCT apply only to first column ‘b.browse_date’ or does DISTINCT apply to all columns I named 'b.browse_date, ‘b.user_id’, ‘c.user_id’ and ‘p.user_id’?

Many thanks!

The DISTINCT keyword applies across all of the columns as a whole, meaning that each row is distinct. Therefore, some rows may have the same value for some columns, but as long as at least one column value differs, then the whole row is considered distinct.

That makes absolute sense. Thanks for the explanation!