Hi Folks,
I am looking for an elegant way of computing the percentage error. The following code works, but I don't want to repeat the same statment to compute the % error.
select NODE,
count(*) "Total_Errors",
sum(case when (CODE = 3) then 1 else 0 end) "Code_3",
(sum(case when (CODE = 3) then 1 else 0 end)/count(*))*100
from T;
The desired output should have the following columns
NODE Total_Errors Code_3 Percent_Error
Thanks in advance
rogers42
I am looking for an elegant way of computing the percentage error. The following code works, but I don't want to repeat the same statment to compute the % error.
select NODE,
count(*) "Total_Errors",
sum(case when (CODE = 3) then 1 else 0 end) "Code_3",
(sum(case when (CODE = 3) then 1 else 0 end)/count(*))*100
from T;
The desired output should have the following columns
NODE Total_Errors Code_3 Percent_Error
Thanks in advance
rogers42