Case statement to sum values - T-SQL
Posted on 2016-10-13
I'm trying to write a case statement that sums up values, but the one below is producing null values. What am I doing wrong? *In a nutshell, (NL * 3%) + (DP * 1%) + (PR) = NR.
when METRIC_CD = ''NL'' then
MTD_ACT * 0.03 else null end) +
(case when METRIC_CD = ''DP'' then
MTD_ACT * 0.01 else null end) +
(case when METRIC_CD = ''PR'' then
MTD_ACT * 1 else null end)) as NR
Below is the data as it appears in the table:
Thank you for your tremendous assistance.