title: Grouping with multiple columns sql
body: <p>I have two tables <code>Contact</code> and <code>Account</code>, that contains following sample data:</p>
  
  <p><code>Account</code></p>
  
  <pre><code>Account_Number | Account_Name
        1          ABC
        2          XYZ
  </code></pre>
  
  <p><code>Contact</code></p>
  
  <pre><code>ID | Account_Number | Contact_Name
  1           1         Steve
  2           1         Tom
  3           2         Ryan
  </code></pre>
  
  <p>I want to identify all the <code>Account_Names</code> that contains multiple contacts associated.</p>
  
  <p>Desired Output:</p>
  
  <pre><code>Contact_Name | Account_Name
  Steve        | ABC
  Tom          | ABC
  </code></pre>
  
  <p>I tried following query:</p>
  
  <pre><code>Select Distinct c.Contact_Name, a.account_Name
  from Contact c
  Inner join Account a
  on c.Account_Number = a.Account_Number
  group by a.Account_Name, c.Contact_Name
  having count(Account_Name) &gt; 1;
  </code></pre>
  
  <p>This query doesn't return anything, as the grouping is done against both <code>Contact_name</code> and <code>Account_Name</code>.</p>