title: group_concat sqlite and order by
body: <p>I am trying to order within group_concat in sqlite3. This is not supported in the way that it is for mysql, so I CAN NOT do this:</p>
  
  <pre><code>group_concat(logID order by logDateTime DESC)
  </code></pre>
  
  <p>My full query is here, I need logID to be ordered by logDateTime. I read about a subquery method here: <a href="https://stackoverflow.com/questions/1897352/sqlite-group-concat-ordering">Sqlite group_concat ordering</a> but I was unable to get it to work in my query.</p>
  
  <pre><code>SELECT logID,
         NULL AS sessionID,
         logDateTime,
         NULL AS sessionName,
         NULL AS NamesInRandomOrder
  FROM logs
  WHERE sessionID IS NULL
  
  UNION ALL
  
  SELECT NULL,
         sessions.sessionID,
         MAX(logDateTime),
         sessions.sessionName,
         group_concat(logID)
  FROM logs
  JOIN sessions ON logs.sessionID = sessions.sessionID
  GROUP BY sessions.sessionID
  
  ORDER BY 3 DESC
  </code></pre>