sharonsql2013 (5/16/2014)
I am trying to remove Null from my query but fail to do so.There are around 20 different dept names in this table. But I only need to display two based on this case statement..
Select distinct
Case when P.Dept_Value = 'Accounting' Then 'AccountingPerson'
When P.Dept_Value = 'ITServices' Then 'ITPerson'
End Type
From PesonDept P
It returns three values
AccountingPerson
ITPerson
NULL
If I write where P.Dept_Value Is not Null or P.Dept_Value <> Null , it still shows up.
How should I fix it?
You are checking twice...well sort of. 😉
where P.Dept_Value Is not Null
You included a second condition which will not work for NULL and as such it will return those with NULL. You cannot use equality OR inequality when checking for NULL. NULL has no value and therefore is not equal to NOR equal to any known value.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/