title: MySQL group_concat() ordering by case statement values
body: <p>In a MySQL <code>group_concat()</code> clause, I'm trying to order the resulting values of a case statement. The following query configuration properly orders <code>things.name</code> but does not order the 'Non-US' or 'Unknown' values within the same context. </p>
  
  <pre><code>SELECT 
    things.id
    ,group_concat(DISTINCT 
      CASE
      WHEN things.name &lt;&gt; 'United States' THEN 'Non-US'
      WHEN things.name IS NULL THEN 'Unknown'
      ELSE things.name
      END
    ORDER BY name SEPARATOR ', ')
  FROM things
  GROUP BY things.id
  </code></pre>
  
  <p>I want to do something like this, but it's not working:</p>
  
  <pre><code>SELECT 
    things.id
    ,group_concat(DISTINCT 
      (CASE
      WHEN things.name &lt;&gt; 'United States' THEN 'Non-US'
      WHEN things.name IS NULL THEN 'Unknown'
      ELSE things.name
      END) AS new_name
    ORDER BY new_name SEPARATOR ', ')
  FROM things
  GROUP BY things.id
  </code></pre>
  
  <p>Is there a way to sort by "new_name" without using sub-queries/ nested queries?</p>