How to get first value from list of value
You can use the DISTINCT ON of SELECT as in the documentation

SELECT DISTINCT ON (id)
  id, col1, col2
FROM TABLE
ORDER BY id, col1, col2


The difference between SELECT DISTINCT &lt;columns&gt; and SELECT DISTINCT ON (&lt;columns&gt;) &lt;columns&gt; is that the first gives you unique rows across all selected columns .. the second gives you one unique row per column set defined within the parenthesis, but allows for additional columns to be returned.

To specify WHICH additional data is returned, you need to ORDER BY..  DISTINCT will then return the first row for each DISTINCT ON set of columns.