title: SQL Select and separate duplicates from single records from a JDBC ResultSet
body: <p>I currently have the following query </p>
  
  <pre><code>SELECT table1.col1, table2.col2  
  FROM   table1     
      INNER JOIN table2 ON table1.col1=table2.col6  
  WHERE  col3 IN 
             (SELECT col1 
              FROM table3 
              WHERE col4 IN (
                     SELECT col4 
                     FROM table4 
                     WHERE col5 LIKE '%XYZ%'
                 )       
              )  ORDER BY table1.col1 
  </code></pre>
  
  <p>The Result I get is as follows</p>
  
  <pre><code>COL1  |  COL2
  Bob      LA
  BOB      NY
  Charlie  SF
  Donald   Phoenix
  Edward   Chicago
  Edward   DC
  Florence Miami
  George   Sunnyvale
  Helen    Orlando
  Helen    Houston
  </code></pre>
  
  <p>If you observe the results, the following entries are duplicated on Col1 (Bob, Edward, Helen). The following are only single records(Charlie, Donald, Florence, George).</p>
  
  <p>What I want are 2 different queries where  one query should return only the single records and another query should return only the duplicates. "I need BOTH Col1 and Col2 returned from both the queries". I have tried to modify, but either it gives an error or it does not result in any  reults .</p>
  
  <p>Desired result</p>
  
  <p>Query1 result (Only single records)</p>
  
  <pre><code>COL1  |  COL2
  Charlie  SF
  Donald   Phoenix
  Florence Miami
  George   Sunnyvale
  </code></pre>
  
  <p>Query2 result (Only duplicate  records returned)</p>
  
  <pre><code>COL1  |  COL2
  Bob      LA
  BOB      NY
  Edward   Chicago
  Edward   DC
  Helen    Orlando
  Helen    Houston
  </code></pre>