title: sql "group by" to group rows corresponding to same pair
body: <p>I have a table with 2 columns - "primary" and "secondary".  In addition there are other columns too.
  Following is a sample set of rows:</p>
  
  <pre><code>id=1, primary=A, secondary=B, .....
  id=2, primary=C, secondary=D, .....
  ....
  .......
  id=200, primary=B, secondary=A, .....
  id=300, primary=J, secondary=D, .....
  </code></pre>
  
  <p>I need a "GROUP BY" query that will group all rows for which the primary and secondary values belong to same pair of values <strong>regardless of the order</strong>.
  So,
  groups should look as follows:</p>
  
  <pre><code>group=1, nodepair=BA, ....   // (primary=A &amp;&amp; secondary=B) OR (primary=B &amp;&amp; secondary=A)
  group=2, nodepair=JM, ....   // (primary=J &amp;&amp; secondary=M) OR (primary=M &amp;&amp; secondary=J)
  </code></pre>
  
  <p>Thanks.</p>