Starting here? This lesson is part of a full-length tutorial in using SQL for Data Analysis. Check out the beginning.
In this lesson we'll cover:
IS NULL is a logical operator in SQL that allows you to exclude rows with missing data from your results.
Some tables contain null values—cells with no data in them at all. This can be confusing for heavy Excel users, because the difference between a cell having no data and a cell containing a space isn't meaningful in Excel. In SQL, the implications can be pretty serious. This is covered in greater detail in the intermediate tutorial, but for now, here's what you need to know:
You can select rows that contain no data in a given column by using IS NULL.
SELECT *
FROM tutorial_billboard_top_100_year_end
WHERE artist IS NULL OR TRIM(artist) = '';WHERE artist = NULL will not work—you can't perform arithmetic on null values.
Write a query that shows all of the rows for which song_name is null.