title: Using SQL to create an ID X-ref table
body: <p>Using SQL, I am trying to group ids together that are associated together.  For each associated group of ids, I need to keep the minimum value as the group id and then list all distinct values within the group as the unique id.  The input data comes in the sequence shown below and associated ids are always on adjacent rows. </p>
  
  <pre><code>--SAMPLE INPUT DATA  
  CREATE TEMPORARY TABLE INPUT_TBL  
    (ID1  INTEGER,  
     ID2  INTEGER);  
  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 101,105;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 105,102;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 102,105;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 204,210;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 210,203;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 203,210;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 301,302;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 302,303;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 303,307;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 307,305;  
  INSERT INTO INPUT_TBL (ID1,ID2) SELECT 305,307;
  </code></pre>
  
  <p><strong>Input File</strong>  </p>
  
  <pre><code>Id-1 Id-2  
  101  105  
  105  102  
  102  105  
  204  210  
  210  203  
  203  210  
  301  302  
  302  303  
  303  307  
  307  305  
  305  307  
  </code></pre>
  
  <p><strong>Desired Output:</strong>     </p>
  
  <pre><code>Group Id    Unq Id  
  101         101  
  101         105  
  101         102  
  203         204  
  203         210  
  203         203  
  301         301  
  301         302  
  301         303  
  301         307  
  301         305  
  </code></pre>