Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

order and group by month/yyyy

Chri$ADec 31 2014 — edited Dec 31 2014

Hi All,

I have a doubt on how to perform the following:

I'd need to display hiredate from the table employees, grouping by month and year, excluding days, so I did the following

select to_char(hiredate,'mon/yyyy') from employees group by to_char(hiredate,'mon/yyyy')

Now I would need to order by hiredate ( just month and year ) but I can't, It let me order just by to_char(hiredate,'mon/yyyy') which is a string, this returns alphabetical order instead of date chronological order

I also tried order by to_date(to_char(hiredate,'mon/yyyy'),'mon/yyyy') but it orders by day month and year while I need to order just by month and year

Any help appreciated

thank you !

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 28 2015
Added on Dec 31 2014
9 comments
9,126 views