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!

Rollup - getting average

607350Sep 18 2008 — edited Sep 18 2008
I am calculating a total, and a percentage in a query while grouping on a task_id. This works fine, but now I was to add a grand total line, so I thought I would try rollup. However, I want the percentage total to be an average, while the count as a sum.

Can this be done with rollup?

This is my query:
Select COUNT(*) AS total_count,
ROUND (SUM (CASE MET
                  WHEN 'Y' THEN 1
                  ELSE 0 END) / DECODE (COUNT (*), 0, 1, COUNT (*)) * 100,2) AS percent_Met, task_id FROM 
                  METRICS
Group by rollup(task_id)
Thanks!

John

Edited by: JohnA on Sep 18, 2008 10:12 AM To fix query
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2008
Added on Sep 18 2008
4 comments
666 views