title: select 1 row into 2 column query postgresql
body: <p>I have table like this</p>
  
  <pre><code>user_id |          date |        time|
  "1"     |   "2017-01-03"|   "06:59:35"
  "1"     |   "2017-01-03"|   "07:01:17"
  "1"     |   "2017-01-03"|   "12:03:21"
  "1"     |   "2017-01-03"|   "16:06:14"
  "2"     |   "2017-01-03"|   "07:10:52"
  "2"     |   "2017-01-03"|   "07:11:38"
  "2"     |   "2017-01-03"|   "07:12:04"
  "3"     |   "2017-01-03"|   "07:12:06"
  "3"     |   "2017-01-03"|   "09:12:33"
  "3"     |   "2017-01-03"|   "16:13:29"
  </code></pre>
  
  <p>This is my mysql query</p>
  
  <pre><code>SELECT  
      col_user_id as user_id, 
      col_date as tanggal, 
      if(MAKETIME(HOUR(MIN(col_jam),MINUTE(MIN(col_jam),00) &lt;= '12:00', MAKETIME(HOUR(MIN(col_jam),MINUTE(MIN(col_jam),00), NULL) as jam_masuk, 
      if(MAKETIME(HOUR(MAX(col_jam),MINUTE(MAX(col_jam),00) &gt; '12:00', MAKETIME(HOUR(MAX(col_jam),MINUTE(MAX(col_jam),00), NULL) as jam_keluar 
      FROM tb_kehadiran_temp
      WHERE 
      col_date &gt;= LAST_DAY(CURRENT_DATE) + INTERVAL 1 DAY - INTERVAL 2 MONTH
      AND 
      col_date &lt; LAST_DAY(CURRENT_DATE) + INTERVAL 1 DAY
      GROUP BY col_user_id,col_date
  </code></pre>
  
  <p>I want my result like this on postgre query:</p>
  
  <pre><code>user_id | date       | in       | out 
  1       | 2017-01-03 | 06:59:35 | 16:06:14 
  2       | 2017-01-03 | 07:10:52 | null 
  3       | 2017-01-03 | 07:12:04 | 16:13:29
  </code></pre>
  
  <p>and i want to move to other table with condition insert or update if data is exists </p>