I am having a bit of trouble with a query for SQL Server 2008.
I have a table with some values and a category. This category can be e.g. Stock, Bond or NULL.
Then I may want to see everything in my table that is not bonds:
SELECT Value, Name, Currency, Assetclass
FROM MyTable
WHERE Assetclass <> 'Bond'
Here I expect to see all my assets that are Stock and uncategorised (NULL). But instead I only see the stocks. I get the same result as setting my Where-condition to Assetclass = 'Stock'.
I am aware that NULL is treated as an unidentified value, but I would expect it to only disregard rows that contain exactly 'Bond' and keep everything else, but this is apparently not the case?
WHERE (Assetclass <> 'Bond' or Assetclass Is null)??Assetclass <> 'Bond'condition) as well as all null values (satisfies theAssetclass is nullcondition).