Please help - pivot option [message #646423] |
Wed, 30 December 2015 04:18 |
|
lb92
Messages: 3 Registered: December 2015
|
Junior Member |
|
|
hi all,
please help i have a problem with pivot:
i am trying to run this command:
select * from
(
select 'AGG-DIRECT' as label_t ,FLIGHT_RT_AGG_STATUS as status,count(status)
from fs_cdr_control
where FLIGHT_RT_AGG_STATUS in(0,1,2,9)
group by FLIGHT_RT_AGG_STATUS
union all
select 'AGG-ME' as label_t ,hourly_ag_status as status,count(status)
from fs_ME_control
where hourly_ag_status in(0,1,2,9)
group by hourly_ag_status
union all
select 'AGG-RTB' as label_t ,hourly_ag_status as status,count(status)
from FS_RTB_control
where hourly_ag_status in(0,1,2,9)
group by hourly_ag_status
)
pivot
(
count(label_t)
for label_t in ('AGG-DIRECT','AGG-ME','AGG-RTB')
)
order by status;
i am out of ideas why it would not run, it returns me error: ora 00933 sql command not properly ended.
the inside query returns this:
label_t status count(*)
AGG-DIRECT 9 71163
AGG-ME 1 188
AGG-ME 9 70444
AGG-RTB 1 19
AGG-RTB 9 70672
AGG-RTB 0 42
all i want is to make it look like this:
the number are just examples:
this important part is
status AGG-DIRECT AGG-ME AGG-RTB
1 0 10 20
0 50 15 21
2 15 19 5
9 65 15 22
please help,
i am out of my mind.
[Updated on: Wed, 30 December 2015 04:30] Report message to a moderator
|
|
|
|
|
|
|
Re: Please help - pivot option [message #646446 is a reply to message #646445] |
Wed, 30 December 2015 11:46 |
|
lb92
Messages: 3 Registered: December 2015
|
Junior Member |
|
|
There was no problem.
The query i added do the job i asked for, the problem was i mistakenly opened a different test database and it was oracle 10g r2 not 11g.
sorry for the trouble.
next time i will check everything before posting a question.
[Updated on: Wed, 30 December 2015 11:47] Report message to a moderator
|
|
|