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!

SQL on PIVOT

KODSJan 17 2014 — edited Jan 22 2014

Hi All,

I am trying to write a SQL which will generate report which shows by user on each month how many objects created.

select owner, to_char(created,'MON'), count(1) cnt

from dba_objects

group by owner, to_char(created,'MON') order by 1,2;

The above query is giving report. Now I like to see the report in more readable format using PIVOT. I prepared a query but it is throwing error. Please help me in preparing correctly.

select * from (

  select owner,to_char(created,'MON') from dba_object)

pivot(

  count(to_char(created,'MON')) for to_char(created,'MON') in ('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'))

order by owner;

This post has been answered by 915396 on Jan 17 2014
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 19 2014
Added on Jan 17 2014
6 comments
266 views