[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

null output on case statement with computation

Hi,

Kindly assist what can we do to stop generating null values on the output. what can we do to troubleshoot?

Thanks.

Select
cast(avg((case when c.subcategorydescription = 'delivery' then b.score end +
case when c.subcategorydescription = 'listening skill' then b.score end+
case when c.subcategorydescription = 'communication skill' then b.score end)/3)*@customerinteraction as decimal(10,2))as [Average Total Customer Interaction],
0
EdwardPeter
Asked:
EdwardPeter
2 Solutions
 
mcmonapCommented:
Hi

To trouble shoot try simplifying the case statement, see if any of the results are null if you just run the case statements seperately, you will then need to isolate the nulls either by omitting them with a where clause or by using ISNULL to replace the null with another value ie ISNULL(b.score, 0):

Select      case
            when c.subcategorydescription = 'delivery' then b.score
      end deliv,
      case
            when c.subcategorydescription = 'listening skill' then b.score
      end list_sk,
      case
            when c.subcategorydescription = 'communication skill' then b.score
      end com_sk
--the rest of your query goes here
0
 
NawalKishore1976Commented:
Use Isnull(select statement, 0)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now