Amour22015
asked on
SQL Server 2014 - Returning a Percentage of 2 Summed Values
Hi Experts,
I have this part of a calculation:
but the outcome Example:
TotalVul = 64
ResolvedVul60 = 5
I get:
0.00
Please help and thanks...
I have this part of a calculation:
Cast(ISNULL(Sum(ResolvedVul60)/NULLIF(Sum(TotalVul), 0) * 100, 0) as Decimal(18,2)) as [Percent 60]
but the outcome Example:
TotalVul = 64
ResolvedVul60 = 5
I get:
0.00
Please help and thanks...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or this -
Also note that the numerator should be numeric.
Also note that the numerator should be numeric.
/*------------------------
SELECT Cast(ISNULL( CAST ( Sum(5) AS decimal(18,9)) / NULLIF(Sum(64), 0) * 100, 0) as Decimal(18,2)) as [Percent 60]
------------------------*/
Percent 60
---------------------------------------
7.81
(1 row(s) affected)
ASKER
Thanks for helping...
Welcome !!
Open in new window