How do I filter null values from a query? I am trying to filter the null values from the following query and it keeps giving me 2 records instead of 1.

Here is my base query


The following query brings me back 2 results and I only need to see one result as there is only one vender for vendor_id 91.  it's giving me a record for the null and an 'N' for the result of my case statement.

SELECT CASE WHEN vs.User_Data_Field1 = '14' THEN 'Y'
            WHEN vs.User_Data_Field2 = '14' THEN 'Y'
            WHEN vs.User_Data_Field3 = '14' THEN 'Y'
            WHEN vs.User_Data_Field4 = '14' THEN 'Y' 
            WHEN vs.User_Data_Field5 = '14' THEN 'Y'
            ELSE 'N'
       END USER_DATA_FIELD
FROM RHOP..EDSLKP.VENDOR_SITES VS
where vendor_id = '91' 
GROUP BY VENDOR_ID,VS.USER_DATA_FIELD1,VS.USER_DATA_FIELD2,VS.USER_DATA_FIELD3,VS.USER_DATA_FIELD4,VS.USER_DATA_FIELD5
ORDER BY VENDOR_ID




My question is, How do I code this to only bring back one 'N' for the one vendor?

Thanks for any help
If I'm interpreting your question correctly (that you want to return Y if any User_Data_Field for any matching row is 14), you can do something like:

SELECT CASE WHEN SUM(IIF(User_Data_Field1 = 14, 1, 0)
                    +IIF(User_Data_Field2 = 14, 1, 0)
                    +IIF(User_Data_Field3 = 14, 1, 0)
                    +IIF(User_Data_Field4 = 14, 1, 0)
                    +IIF(User_Data_Field5 = 14, 1, 0)) &gt; 0 THEN 'Y'
ELSE 'N'
END USER_DATA_FIELD
FROM RHOP..EDSLKP.VENDOR_SITES VS
WHERE vendor_id = '91' 
GROUP BY VENDOR_ID
ORDER BY VENDOR_ID


IIF is only supported in SQL 2012 and above, so prior to that you'll have to stick with CASE WHEN.