title: SQL find children that have multiple parent records
body: <p>I have a situation where we have inserted duplicated data into some tables. </p>
  
  <p>Given the following database schema, I want to find all records with s_id and co_id combinations associated to more than 1 record from table A.  The highlighted rows are the rows I'm looking for, based off of finding the duplicates I need to find the id's from table A associated to the duplicate records.</p>
  
  <p>I'm able to group by s_id &amp; co_id to determine potential duplicates, but because Table B is a 1:M, this isn't entirely accurate.</p>
  
  <pre><code>Select c.s_id, c.co_id, Count(*)
  from c 
      INNER JOIN b on c.b_id = b.id
      INNER JOIN a on a.id = b.a_id
  Group By c.s_id, c.co_id
  Having count(*) &gt; 1;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/3FLAx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3FLAx.png" alt="ERD"></a>
  <a href="https://i.stack.imgur.com/kkajC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kkajC.png" alt="enter image description here"></a></p>