title: Using SQL to query a distinct pair based on a similar id
body: <p>I am running into some trouble finding a way to query a pair, based on similar ids on a table.</p>
  
  <p>I have a database schema that consists of something like this:</p>
  
  <pre><code>Class:
      *Course
      *Size
      *Class_ID
  
  Partner:
      *Class_ID
      *Person_ID
      *Partner_ID
  
  Person:
      *Name
      *Person_ID
      *Email
  </code></pre>
  
  <p>When partners are chosen in class, they are given the same partner ID. I am trying to write a query that queries all the partner pairs for 'Economics'. The query should be distinct pairs , ie. a,b and b,a shouldn't both be listed.</p>
  
  <p>So far I have used a Join statement to query everything together.</p>
  
  <pre><code>Select * from Person Join Partner On Person.Person_ID = Partner.Partner_ID
  Join Class On Class.Class_ID = Partner.Partner_ID WHERE Class.Course = 'Economics';
  </code></pre>
  
  <p>This query gives me a list of each individual person who has a partner in economics. I would like to be able to somehow turn this query into pairs.</p>
  
  <p>I think the group_by Partner_ID function might be helpful, but I'm not sure how I would use it.</p>