title: SQLite Select data from multiple rows returned as one row
body: <p>I would like to know whether it is possible to use a SELECT statement in SQLite to merge the data from two rows into one, similar to how is suggested in the SQL Server forum below.  </p>
  
  <p>Consider the scenario below which is based on SQL Server (taken from <a href="http://forums.aspfree.com/microsoft-sql-server-14/merge-the-two-rows-in-one-row-245550.html" rel="noreferrer">http://forums.aspfree.com/microsoft-sql-server-14/merge-the-two-rows-in-one-row-245550.html</a>)</p>
  
  <p>Given there is a table</p>
  
  <h2>Emp</h2>
  
  <p>ID | Name |<br>
  1  |  x |<br>
  1 | P |<br>
  2 | y |<br>
  2 | Q |<br>
  3 | W |  </p>
  
  <p>We want the resulting data from the select statement to output:  </p>
  
  <h2>Emp_Data</h2>
  
  <p>Id | Name-1 | Name-2 |<br>
  1 | x | P |<br>
  2 | y |  Q |<br>
  3 | w | |</p>
  
  <p>The answer in the post suggests the following SQL as a possible solution:</p>
  
  <pre><code>SELECT 
     a.ID, 
     [Name-1] = ISNULL(( 
     SELECT TOP 1 Name 
     FROM emp 
     WHERE ID = a.ID),''), 
     [Name-2] = ISNULL(( 
     SELECT TOP 1 b.Name 
     FROM emp b 
     WHERE b.ID = a.ID 
         AND Name NOT IN( 
             SELECT TOP 1 Name 
             FROM emp 
             WHERE ID = b.ID 
         )),'') 
  FROM emp a 
  GROUP BY a.ID   
  </code></pre>
  
  <p>Using SQLite is it possible to generate the columns [Name-1] &amp; [Name-2] using nested SELECT statements like we can do above in SQL Server?</p>