MarcCharbo
MarcCharbo

Reputation: 207

SQL Query: Count Distinct with Condition

This is my simplified table:

 is_clicked | direct_lead_id 
------------+----------------
 true       |        4074448 
 false      |        4074448 
 true       |        4074448

I would like to run a query on this to get a distinct count of the direct_lead_id when is_clicked = True. So the result of my query would be 1 in this case. If I added a line to the above table, let say: true| 407449. Then I would want to get 2.

Upvotes: 1

Views: 646

Answers (1)

asmgx
asmgx

Reputation: 7984

select count(distinct direct_lead_id ) 
from my_table
where is_clicked = true

Upvotes: 3

Related Questions