Help with Pivot Query
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!