title: using something like group_concat on clickhouse
body: <p>I'm trying to get a result of</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>types</th>
  <th>name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>fruit</td>
  <td>banana, apple, guaba, strawberry</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>from a table with database like</p>
  <p>table: fruits</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>types</th>
  <th>name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>fruit</td>
  <td>banana</td>
  </tr>
  <tr>
  <td>fruit</td>
  <td>apple</td>
  </tr>
  <tr>
  <td>fruit</td>
  <td>guaba</td>
  </tr>
  <tr>
  <td>fruit</td>
  <td>strawberry</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I know with MySQL I can use group_concat to get the result I want by using</p>
  <pre><code>SELECT group_concat(name), types FROM fruits
  </code></pre>
  <p>I have done my research and people recommend me to use groupArray in clickhouse to obtain similar result but this is not what I want. Because when I use</p>
  <pre><code>SELECT groupArray(name), types FROM fruits GROUP BY types
  </code></pre>
  <p>it gives me result of</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>types</th>
  <th>name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>fruit</td>
  <td>apple, banana, banana, strawberry,strawberry,strawberry, guaba,guaba,guaba,guaba</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>the order of groupArray is mixed up and I can't seem to find an answer to fix the order :(</p>
  <p>is there any way in clickhouse where we can get array of results in order? and why are there duplicated results?</p>
  <p>I can't use groupUniqArray because sometimes my result should be</p>
  <p>banana, apple, guaba, strawberry, strawberry (if strawberry is there twice in DB)</p>
  <p>how do I keep the duplicated data without having it multiplied in order???</p>
  <ul>
  <li>I have data of input_time and key so my table is something like</li>
  </ul>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>types</th>
  <th>name</th>
  <th>input_time</th>
  <th>key</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>fruit</td>
  <td>banana</td>
  <td>01:01</td>
  <td>01</td>
  </tr>
  <tr>
  <td>fruit</td>
  <td>apple</td>
  <td>01:02</td>
  <td>01</td>
  </tr>
  <tr>
  <td>fruit</td>
  <td>guaba</td>
  <td>01:03</td>
  <td>02</td>
  </tr>
  <tr>
  <td>fruit</td>
  <td>strawberry</td>
  <td>01:04</td>
  <td>03</td>
  </tr>
  <tr>
  <td>fruit</td>
  <td>strawberry</td>
  <td>01:05</td>
  <td>04</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>and forgetting about 'types', I want to get result of grouped names in DB saved order (input_time order) group by key. How should I change my query??</p>
  <p>I've tried</p>
  <p><code>SELECT groupArray(name), key FROM fruits GROUP BY key ORDER BY input_time</code></p>
  <p>but it does not give me the result I want..</p>