title: SQL - ordering does not work with LENGTH function
body: <p>I'm trying to sort out my query based on <code>V.SITES_CODE</code>. It works without the <code>LENGTH</code> function, but with the function the order is completely random. Can someone help here is the code:</p>
  
  <pre><code>SELECT     V.CODE_OF_HOLIDAY, V.SITES_CODE, A.SITES_NAME, D.DESCRIPTION
  FROM       ZZZ_SITES_VISITED V, ZZZ_SITES_AVAILABLE A, ZZZ_HOLIDAY_DETAILS H, ZZZ_DIFFICULTY_RATINGS D
  WHERE      V.CODE_OF_HOLIDAY = H.CODE_OF_HOLIDAY
  AND        A.SITES_CODE = V.SITES_CODE(+)
  AND        H.DIFFICULTY_RATING = D.HOLIDAY_DIFICULTY
  AND        H.CODE_OF_HOLIDAY = V.CODE_OF_HOLIDAY
  AND        LENGTH(D.DESCRIPTION) &gt; 6;
  </code></pre>