title: How to remove duplicates, which are generated with array_agg postgres function
body: <p>Does anyone an idea how to rewrite following SQL query to generate results, that would contains only one occurrence of name? (results grouped by user).</p>
  
  <p><strong>The query</strong></p>
  
  <pre><code>SELECT array_to_string(array_agg(CONCAT(u.firstname, ' ', u.lastname)), ', ')
  FROM log_has_item logitem
    INNER JOIN log log ON log.id = logitem.log_id
    INNER JOIN worker u ON log.worker_id = u.id
  WHERE logitem.company_id = 1
  </code></pre>
  
  <p>Executable query is avaiable on <strong><a href="http://sqlfiddle.com/#!15/b911f/5" rel="noreferrer">sqlfiddle.com</a></strong>. 
  Click on Run SQL button and you will result, which contains <em>Frantisek Smith</em> twice</p>