title: SQLite Query to group columns
body: <p>I want to write a query to group my two columns based on  third column and show result in a row as shown below in SQLite CAn anybody guide me how can I write query for such structure
  Table Structure</p>
  
  <pre><code>CREATE TABLE `Table1` (
  `Variable_col`  TEXT,
  `TimeComes_Col` datetime,
  `TimeGoes_Col`  datetime)
  </code></pre>
  
  <p>Dummy Data</p>
  
  <pre><code>Insert Into Table1 Values('var1','2017-03-16 10:00:00',''),('var1','','2017-03-16 10:05:00'),('var1','2017-03-16 10:10:00',''),('var2','2017-03-16 10:15:00','')
  </code></pre>
  
  <p>Tried So far but not getting result as wanted</p>
  
  <pre><code>WITH RECURSIVE cte1 as(select Variable_Col,TimeComes_Col, (SELECT COUNT()+1 FROM ( SELECT DISTINCT TimeComes_Col FROM Table1 AS t WHERE TimeComes_Col &lt; Table1.TimeComes_Col )) as rn from Table1 where TimeComes_Col &lt;&gt; ''),
  </code></pre>
  
  <p>cte2 as(select TimeGoes_Col, (SELECT COUNT()+1 FROM (SELECT DISTINCT TimeGoes_Col FROM Table1 AS t WHERE TimeGoes_Col &lt; Table1.TimeGoes_Col )
  )as rn from Table1 where TimeGoes_Col &lt;> '')select Variable_Col, TimeComes_Col, TimeGoes_Col from cte1 a left join cte2 b on a.rn = b.rn</p>
  
  <p><a href="https://i.stack.imgur.com/bEmx7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bEmx7.png" alt="enter image description here"></a></p>