title: How to aggregate on first value in postgres sql?
body: <p>In this postgres query</p>
  
  <pre><code>SELECT
      q.*,
      q.user_id = 1 mine,
      first(u.username) username,
      sum(case when v.answer=0 then 1 else 0 end) no_count,
      sum(case when v.answer=1 then 1 else 0 end) yes_count
  FROM question q 
  JOIN "user" u ON q.user_id=u.id
  JOIN vote v ON v.question_id=q.id
  GROUP BY q.id
  ORDER BY q.date_created desc 
  LIMIT 20
  OFFSET 0
  </code></pre>
  
  <p>It says I need an aggregate on <code>username</code>. In this case, I am getting questions, and each question is created by some user. I join on votes, but group by the question id, so before grouping the username field will be the same for each unique question. So that means when aggregating, really I can pick any value since it's all the same. However I can't find any aggregate function to use. I tried random, first, last, any, but none work or even defined.</p>
  
  <p>Does anyone know how to handle this?</p>