title: getting first row in postgres query
body: <p>I am querying some data from 2 tables using inner join.</p>
  
  <p>here is the query,</p>
  
  <pre><code>test_db=&gt; select api_booking.install_ts, api_user.id from api_booking inner join api_user on api_booking.user_id=api_user.id and api_booking.status='completed' limit 20 ; 
            install_ts           | id 
  -------------------------------+----
   2016-09-15 09:53:42.511367+00 |  9
   2016-10-12 11:37:11.438715+00 |  9
   2016-10-21 08:55:49.57813+00  |  9
   2017-02-27 06:12:17.362996+00 |  9
   2017-02-27 06:24:59.316051+00 |  9
   2017-02-28 06:15:35.00841+00  |  9
   2017-02-28 06:34:57.766365+00 |  9
   2017-05-23 14:40:54.831525+00 | 14
   2017-06-05 07:47:39.78306+00  | 17
   2017-06-05 07:55:30.171103+00 | 17
   2016-12-06 06:47:43.860581+00 | 19
   2016-09-09 07:34:58.40589+00  | 20
   2016-11-16 09:09:24.466439+00 | 24
   2016-10-03 02:52:24.419793+00 | 24
   2017-05-02 03:48:02.843209+00 | 24
   2017-05-08 10:01:45.77093+00  | 24
   2016-09-09 12:08:27.503695+00 | 27
   2016-09-10 10:05:44.617737+00 | 27
   2016-09-11 10:08:22.791411+00 | 27
   2016-09-12 08:56:31.462979+00 | 27
  (20 rows)
  </code></pre>
  
  <p>Now, I only want the first row from each user_id.</p>
  
  <p>Like this, </p>
  
  <pre><code>          install_ts           | id 
  -------------------------------+----
   2016-09-15 09:53:42.511367+00 |  9
   2017-05-23 14:40:54.831525+00 | 14
   2017-06-05 07:47:39.78306+00  | 17
   2016-12-06 06:47:43.860581+00 | 19
   2016-09-09 07:34:58.40589+00  | 20
   2016-11-16 09:09:24.466439+00 | 24
   2016-09-09 12:08:27.503695+00 | 27
  </code></pre>
  
  <p>What query should I use for this ?</p>