title: How to set "ORDER BY" for two cases?
body: <p>In mysql, I need to set the "ORDER BY" for two cases: name or mod_1, depending on what the user selected in a combobox. My query is:</p>
  
  <pre><code>SELECT
      name,
      SUM(IF(mod = 1, 1, 0)) AS mod_1,
      SUM(IF(mod = 2, 1, 0)) AS mod_2,
      SUM(IF(mod = 3, 1, 0)) AS mod_3
  FROM
      DW_RM_Log
  WHERE
      ...
  ORDER BY
      name (or mod_1 DESC)
  </code></pre>
  
  <p>Is it possible to do this in mysql or I need to code it in php? Or both?</p>