Filter rows with NULL
Write a filter that treats missing values as a separate case.
What you are trying to do
A queue report should show ready items and items whose state has not been set.
Work through it
- Read the synthetic state values.
- Check how the predicate handles NULL and the excluded state.
- Change one test value and predict whether its row remains.
Check your work
The result includes ready and unset rows and excludes held rows.
Practice SQL
Open in SQL FlowSELECT ItemId, State FROM (VALUES (1, CAST(N'Ready' AS nvarchar(10))), (2, N'Hold'), (3, NULL)) AS QueueItem(ItemId, State) WHERE State IS NULL OR State <> N'Hold';
Commands in this lesson
Next lesson Order a short result