Oracle date / order by question

Posted by user561793 on Stack Overflow See other posts from Stack Overflow or by user561793
Published on 2011-01-04T19:33:04Z Indexed on 2011/01/04 19:53 UTC
Read the original article Hit count: 138

Filed under:
|
|

I want to select a date from oracle table formatted like select (to_char(req_date,'MM/YYYY')) but I also want to order the result set on this date format.

I want them to be ordered like dates not strings.

Like this

09/2009
10/2009
11/2009
12/2009
01/2010
02/2010
03/2010
04/2010
05/2010
06/2010
07/2010
08/2010
09/2010
10/2010
11/2010
12/2010

Not like

01/2010
02/2010
03/2010
04/2010
05/2010
06/2010
07/2010
08/2010
09/2009
09/2010
10/2009
10/2010
11/2009
11/2010
12/2009
12/2010

Any way to do this in sql?

full sql is select (to_char(req_date,'MM/YYYY')) as monthYear,count(req_id) as count from REQUISITION_CURRENT t group by to_char(req_date,'MM/YYYY')

Thanks

© Stack Overflow or respective owner

Related posts about sql

Related posts about Oracle