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!

Sum on CASE SQL QUERY

Raj AruApr 6 2017 — edited Apr 6 2017

SELECT

m.target_name,

max(case when m.metric_column = 'flash_recovery_area_size' then m.value/1024/1024 end) as  TOTAL_FRA_SIZE_MB,

max(case when m.metric_column = 'reclaimable_area' then m.value end) as RECLAIMB_PERCENTAGE,

max(case when m.metric_column = 'nonreclaimable_area' then m.value end) as NON_RECLAIMB_PERCENTAGE,

max(case when m.metric_column = 'usable_area' then m.value end) as FREE_PERCENTAGE,

max(case when m.metric_column = 'usable_area' then 100 - m.value end ) as USD

--max((case when m.metric_column = 'usable_area' then 100 - m.value]) + (case when m.metric_column = 'reclaimable_area' then m.value) ) as TOTAL

FROM   sysman.mgmt$metric_current m, sysman.mgmt$target_type t

WHERE  ( t.target_type = 'rac_database' AND t.type_qualifier2  = 'Primary')

AND m.target_guid = t.target_guid

AND m.metric_guid = t.metric_guid

AND t.metric_name in ('ha_flashrecovery','Recovery_Area')

AND t.metric_column in ('flash_recovery_area_size','Free_Space','usable_area','nonreclaimable_area','reclaimable_area')

group by m.target_name

order by USD desc

/

In the above query I want to sum RECLAIMB_PERCENTAGE and USD alias columns as TOTAL . How to do it ... The commented line I have tried but it is not working

--max((case when m.metric_column = 'usable_area' then 100 - m.value]) + (case when m.metric_column = 'reclaimable_area' then m.value) ) as TOTAL

This post has been answered by Frank Kulash on Apr 6 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 4 2017
Added on Apr 6 2017
2 comments
2,410 views