If I have three columns:
orderNumber, name, email
and I would like to count how many unique emails are in the table how would I go about doing so?
A statement like:
SELECT count(email) FROM orders
gives me the total count.
I tried SELECT DISTINCT count(email) FROM orders
but that does not seem to be giving me the numbers I am expecting.
Counting unique / distinct rows in Excel is akin to counting unique and distinct values, with the only difference that you use the COUNTIFS function instead of COUNTIF, which lets you specify several columns to check for unique values.
Identify the cell you want to display the count of unique values and enter the formula. The formula to count unique values is =COUNTUNIQUE(A1:A10).
use
SELECT count( DISTINCT(email) ) FROM orders
Distinct provide unique email ids and then simply count them.
SELECT count(DISTINCT(email)) FROM orders
its different from your posting, since its filters out the duplicates before counting it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With