Reputation: 319
I have two tables like
table1 table2 ------------ ---------------- col1 col2 col1 col2
I need to count the distinct col1 from table1 if itis matching with table2 col1
note: table2 col1 also distinct
Upvotes: 0
Views: 55
Reputation: 261
select count(distinct table1.col1)
from table1,table2
where table1.col1=table2.col1
As you select the distinct col of table1, and set the join, the col1 of table2 will also be selected distinctly.
Upvotes: 1