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!

Help with Pivot Query

user260559Jun 26 2012 — edited Jun 26 2012
I'm trying to write a pivot (by day) query that includes a count of events that happen based on a field not being null. In the same query I'd like to include the total events (null or not) so that I can get a ratio.

i.e. this is what I have, how can I add the total count as a final column( whether g is null or not for all days).

select x,y,z,
sum (decode ( to_char (timestamp, 'YYYY-MM-DD', '2012-06-09', count ) ) JUNE_09
sum (decode ( to_char (timestamp, 'YYYY-MM-DD', '2012-06-10', count ) ) JUNE_10
from ( select x, y, z, timestamp, count(*) count
from ab
where g is not null
group by x,y,z)
group by x,y,z.

This is 10g.

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2012
Added on Jun 26 2012
4 comments
172 views