title: Count rows only if the count matches
body: <p>How can I achieve something like this?</p>
  
  <pre><code>select count(distinct a.name) 
  from table_a as a 
  where (
      select count(*) 
      from table_b as b 
      where b.id = a.id
    ) = (
      select count(*) 
      from table_c as c 
      where c.id = a.id
  );
  </code></pre>
  
  <p>I want to count rows only if the count in the two different tables related to first are having the same count of IDs. Assume that we are using PostgreSQL.</p>