Session Ready
Exercise

Imputing missing values (I)

In the previous exercise, you looked at the non-missing values in the IncidentState column. But what if you want to replace the missing values with another value instead of omitting them? You can do this using the ISNULL() function. Here we replace all the missing values in the Shape column using the word 'Saucer':

SELECT  Shape, ISNULL(Shape, 'Saucer') AS Shape2
FROM Incidents

You can also use ISNULL() to replace values from a different column instead of a specified word.

Instructions
100 XP
  • Write a T-SQL query which only returns rows where IncidentState is missing.
  • Replace all the missing values in the IncidentState column with the values in the City column and name this new column Location.