Let me start by creating and populating a small table with a couple of missing values in some cells, denoted by the reserved word NULL in SQL Server:
USE AdventureWorksDW2017;GODROP TABLE IF EXISTS dbo.NULLTest;GOCREATE TABLE dbo.NULLTest( c1 INT NULL, c2 INT NULL, c3 INT NULL);GOINSERT INTO dbo.NULLTest VALUES(1, NULL, 3),(4, 5, 6),(NULL, 8, 9),(10, 11, 12),(13, NULL, NULL);GO
The content of the table is as follows:
c1 c2 c3----------- ----------- -----------1 NULL 34 5 6NULL 8 910 11 1213 NULL NULL
In T-SQL, you can use the ISNULL() and COALESCE() functions to work with NULLs. The first one has only two parameters and returns the value of the first parameter, if it is not NULL, and the values of the second parameter ...