Interview › COUNT DISTINCT

SQL interview: COUNT(*) vs COUNT(col) vs COUNT DISTINCT

COUNT(*) is rows. COUNT(col) skips NULL. COUNT(DISTINCT col) skips NULL and doubles.

Prompt. How many orders, how many with an email, how many different customers.

Hint: COUNT(*), COUNT(email), COUNT(DISTINCT customer_id)

COUNT(DISTINCT) + another DISTINCT is usually two questions, not one fancy COUNT.

Then write it on a ticket

Monday is free. A colleague asks, you type, we mark it.

Clock in free