title: SQL query to return only first occurance of one column value
body: <p>I am not sure how to ask this question... but here it goes. </p>
  
  <p>I have a table called <code>lists</code> that has four columns, <code>id</code>, <code>name</code>, <code>type</code>, and <code>group</code>. The <code>type</code> column values are not unique and is a text column. I need a query to return <code>id</code> and <code>type</code> from table <code>lists</code>, but I only need one of each <code>type</code>. It should also be in alphabetical order. It can be the first occurrence of each type. </p>
  
  <p>In postgreSQL 9.4.5 I have tried <code>select distinct list_type, id from lists order by list_type;</code>, but this of course returns duplicate types that have unique ids. </p>
  
  <p>I only need the first occurrence of each <code>type</code> and that <code>id</code>. </p>
  
  <p>Some sample data:</p>
  
  <pre><code>
                    id                  |           type            
  --------------------------------------+--------------------------------
   0014dea9-f73f-46d0-bf7d-d52717029582 | invest_fees
   004665b5-4657-4cbc-8534-1aa9e4ef305f | invest_fees
   00910f6c-bdf0-4991-ac0c-969b3b9c6b84 | invest_fees
   009ed283-531b-4d7b-b51d-0c0e0e7a5707 | countries
   00b4f8e2-ae47-4083-ae6e-8d6dbaa2cd63 | invest_fees
   00ca1972-cf70-4fa2-bfde-bc89fce19433 | invest_fees
   00feb6a2-4ee7-4e31-8780-cb5938587669 | countries
   010777bc-7e74-4c13-8808-4c35cfdbf988 | pick_banks
   01852693-7560-4de5-a534-0519e7c04c51 | countries
   01bee5a4-23f7-427d-9b84-4c707154a812 | countries
   01bf29f9-70af-4b3c-b7f9-d01e0f0f142c | invest_fees
   01d51fe3-4c32-4d21-b38c-8e84a92ff0aa | invest_fees
   01d981dd-13d4-4098-a7e3-bd1bb5f02f2b | countries
   01de77bb-ff82-4c3c-b26f-f3829d84dd29 | invest_fees
   01df6e6c-9a77-4b83-a825-09949768df54 | countries
   01f11d01-f490-48a9-b21c-803f7c03f5f6 | invest_mtos
  </code></pre>