title: Oracle date to_char group and order by
body: <p>I am working to migrate my queries from mysql to oracle. In mysql I am using query to get only month</p>
  
  <pre><code>SELECT DATE_FORMAT(IDATEIN, '%M-%Y') as MY 
    FROM ATTENDANCE 
   GROUP BY MY 
   ORDER BY IDATEIN DESC
  </code></pre>
  
  <p>which giving me results like</p>
  
  <pre><code>MYDATE
  DEC-2016
  NOV-2016
  OCT-2016
  </code></pre>
  
  <p>My table contains</p>
  
  <pre><code>IDATEIN
  2016-12-01
  2016-12-01
  2016-12-01
  2016-10-01
  2016-11-01
  </code></pre>
  
  <p>In oracle I am trying to use this</p>
  
  <pre><code>  SELECT TO_CHAR(DATEIN, 'MON-YYYY') AS MY 
      FROM HRM_ATTENDANCE 
     GROUP BY TO_CHAR(DATEIN, 'MON-YYYY') 
     ORDER BY TO_CHAR(DATEIN, 'MON-YYYY')
  </code></pre>
  
  <p>But it ordering to abphables, like</p>
  
  <pre><code> APR-2016
   APR-2017
   AUG-2016
   FEB-2016
   FEB-2017
  </code></pre>
  
  <p>Please help</p>
  
  <p>Oracle Result</p>
  
  <p><a href="https://i.stack.imgur.com/N6QVq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N6QVq.jpg" alt="Oracle Result"></a></p>
  
  <p>Mysql Result</p>
  
  <p><a href="https://i.stack.imgur.com/vUDai.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vUDai.jpg" alt="Mysql Result"></a></p>