null output on case statement with computation

Posted on 2005-05-13
Last Modified: 2010-03-19

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


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],
Question by:EdwardPeter
    LVL 15

    Accepted Solution


    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,
                when c.subcategorydescription = 'listening skill' then b.score
          end list_sk,
                when c.subcategorydescription = 'communication skill' then b.score
          end com_sk
    --the rest of your query goes here
    LVL 3

    Assisted Solution

    Use Isnull(select statement, 0)

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now