title: How to write a correct order by case
body: <p>I have this problem, if I'm using the <code>sql</code> statement normally, i mean like this: <br></p>
  <pre><code>SELECT p.id_plecari, p.id_aeroport, p.id_clasa, p.id_avion, p.data, p.ora, c.pret, av.nume, a.Nume, a.Locatie
      from plecari p, clasa c, avioane av, aeroport a
  where 
     p.id_aeroport = a.id_aeroport
     AND p.id_clasa = c.id_clasa
     AND p.id_avion = av.id_avion
     AND p.id_plecari not in(SELECT r.id_plecare from rezervari r WHERE r.id_client = idClient) 
     ORDER BY p.id_clasa ASC;
  </code></pre>
  <p>Everything is listed as I expected, perfect like in <a href="https://i.stack.imgur.com/BkfqG.png" rel="nofollow noreferrer">this picture</a><br>
  But in the moment when I add the <code>CASE</code> statement, everything is messed up:</p>
  <pre><code>BEGIN
  SELECT p.id_plecari, p.id_aeroport, p.id_clasa, p.id_avion, p.data, p.ora, c.pret, av.nume, a.Nume, a.Locatie
      from plecari p, clasa c, avioane av, aeroport a
      where 
          p.id_aeroport = a.id_aeroport
          AND p.id_clasa = c.id_clasa
          AND p.id_avion = av.id_avion
          AND p.id_plecari not in(SELECT r.id_plecare from rezervari r WHERE r.id_client = idClient) ORDER BY 
          (CASE 
      WHEN (orderby = 1 AND orderas = false) THEN p.id_plecari
      WHEN (orderby = 2 AND orderas = false) THEN av.nume
    END) ASC ,
    (CASE 
      WHEN (orderby = 1 AND orderas = true) THEN p.id_plecari
      WHEN (orderby = 2 AND orderas = true) THEN av.nume
    END) DESC;
  END
  </code></pre>
  <p>Everything looks <a href="https://i.stack.imgur.com/vSaEA.png" rel="nofollow noreferrer">like this</a>!</p>