Creating a Compound NULLIF in AVG Function With SqlServer

My use case is I’ve got a session survey column on the Silicon Valley Code Camp session evaluation page.  The results of a question like “How is this course overall” can be 0,1,2,3,4,5 where 0 means the person did not answer the question and 5 means the person chose not applicable.  I want to throw away both of these answers in my average using the SqlServer AVG function (knowing AVG does not include nulls). With some help from StackOverflow and some creative nesting, I came up with the following Sql. It feels ugly and not scalable, but it does work.  I’m open to other suggestions but thought I’d post it anyhow as a first pass just to see what others think.  I’m including the full query so it’s clear what I’m going … Continue Reading


Get every new post delivered to your Inbox

Join other followers: