I have the query below:
SELECT DISTINCT [col1], CASE WHEN [Col2] = 'Text1' THEN 'Text2' WHEN [col3] IS NULL THEN 'Text3' ELSE [col3] END AS [col3], 'Text4' AS [col4] FROM Table1 WHERE ([col3] IN ('text5','text6') OR [col3] IS NULL)
My questions are:
- what happens first and which second? The CASE statement (i.e. the text replacements that will form col3 or the WHERE statement (i.e. the filtering of the original col3)?
- why when I replace the last WHERE statement with the following, I get a different number of results?
WHERE [col3] IN ('text5','text6',NULL)