title: Comparing the outputs of two SQL queries?
body: <p>I'm having some trouble with a complex SQL query, and I would appreciate any help. I've simplified the tables &amp;&amp; names.</p>
  
  <pre><code>SCHEMA:   
  
    Business Account
      payment_account_id
      business_id
  
    Business Misc
      business_user_id
      business_id
  
    Payment Account
      business_user_id
      payment_account_id
  </code></pre>
  
  <p>I need a SQL query that takes all of the businesses that have more than one payment account, all of the business users that have more than one payment account, and gives me an overlap of when those payment accounts have the same id. </p>
  
  <p>So far I've gotten:</p>
  
  <pre><code>business_with_multiple_accounts = 
  
  select * 
  from "Business Account" 
  group by business_id 
  having count(distinct payment_account_id) &gt; 1;
  
  users_with_multiple_accounts =
  
  select * 
  from "Payment Account" 
  group by business_user_id 
  having count(distinct payment_account_id) &gt; 1;
  </code></pre>
  
  <p>I think I just need to compare these two outputs (but I could be wrong!) but I'm unsure of how to proceed. I've tried nesting the queries in various ways, as well as using the "Business Misc" table in a three-way-join.</p>
  
  <p>Thank you for any help you can give!</p>