If you want to add a and b and either may be null, you could use coalesce, which returns the first non-null parameter you pass it:

coalesce(a+b, a, b)

So in this case, if neither parameter is null, it will return the sum. If only b is null, it will skip a+b and return a. If a is null, it will skip a+b and a and return b, which will only be null if they are both null.

If you want the answer to be 0 rather than null if both a and b are null, you can pass 0 as the last parameter:

coalesce(a+b, a, b, 0)

Do consider @erwins answer - null might not be the right thing to be using.

Answer from rjmunro on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_null_values.asp
SQL NULL Values - IS NULL and IS NOT NULL
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Certificate SQL Training ... A field with a NULL value is a field with no value. If a field in a table is optional, it is possible to insert a new record or update a record without adding a value ...
๐ŸŒ
w3resource
w3resource.com โ€บ sql โ€บ insert-statement โ€บ insert-null.php
Sql inserting NULL values - w3resource
-- This SQL code attempts to insert a new row into the 'agents' table. -- INSERT INTO statement begins INSERT INTO agents -- Specifies the table 'agents' where the data will be inserted VALUES ("A001","Jodi","London",.12,NULL); -- Specifies the values to be inserted into each column of the table: -- "A001" will be inserted into the 'agent_code' column (assuming it's a string data type) -- "Jodi" will be inserted into the 'agent_name' column -- "London" will be inserted into the 'working_area' column -- .12 will be inserted into the 'commission' column (assuming it's a numeric data type) -- NULL will be inserted into the 'salary' column, assuming it allows NULL values
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sql โ€บ how-to-insert-rows-with-null-values-in-sql
How to Insert Rows with NULL Values in SQL? - GeeksforGeeks
July 23, 2025 - INSERT INTO WORKER VALUES('SAM','ONTARIO',NULL); INSERT INTO WORKER VALUES('TIM',NULL,56); INSERT INTO WORKER VALUES(NULL,'CAIRO',43); INSERT INTO WORKER VALUES(NULL,'MUMBAI',NULL); INSERT INTO WORKER VALUES(NULL,NULL,NULL);
๐ŸŒ
Scaler
scaler.com โ€บ topics โ€บ sql โ€บ null-value-in-sql
NULL Value in SQL - Scaler Topics
April 20, 2022 - MySQL provides us with some functions which are intended to be used with NULL values. These functions are ISNULL() and IFNULL(). When we are inserting the data in the tables, it is possible that data for some fields are not available. Instead ...
๐ŸŒ
Embarcadero
docwiki.embarcadero.com โ€บ InterBase โ€บ 2020 โ€บ en โ€บ Inserting_Rows_with_NULL_Column_Values
Inserting Rows with NULL Column Values - InterBase
EXEC SQL INSERT INTO DEPARTMENT (DEPT_NO, DEPARTMENT) VALUES (:newdept_no, :newdept_name); Because HEAD_DEPT, MNGR_NO, and BUDGET are not specified, InterBase sets the NULL value flag for each of these columns. Note: If a column is added to an existing table, InterBase sets a NULL value flag for all existing rows in the table.
Find elsewhere
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ insert-null-value-into-int-column-in-mysql
Insert NULL value into INT column in MySQL?
You can insert NULL value into an int column with a condition i.e. the column must not have NOT NULL constraints. The syntax is as follows. INSERT INTO yourTableName(yourColumnName) values(NULL); To under
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ sql โ€บ sql-null-values.htm
SQL - NULL Values
You can insert NULL values into the columns where we did not use NOT NULL. Let us create a table with the name CUSTOMERS in the SQL database using the CREATE statement as shown in the query below โˆ’ ยท CREATE TABLE CUSTOMERS( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS ...
๐ŸŒ
Database Journal
databasejournal.com โ€บ home โ€บ features
Working with NULL Values in SQL | DatabaseJournal.com
March 9, 2023 - In this SQL example, we selected all values from the employees table where the phone_number column is not NULL. ... If you add a NULL value to a numeric value, the result is always NULL. The same goes for any mathematical operation involving a NULL value.
๐ŸŒ
SQL Authority
blog.sqlauthority.com โ€บ home โ€บ sql server โ€“ adding values containing nulls
SQL SERVER - Adding Values Containing NULLs - SQL Authority with Pinal Dave
October 19, 2020 - Now let us add the data of the column and we are going to use the simple operator of PLUS (+) as well as function ISNULL which actually will check if the column value is NULL then will convert it to zero.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sql โ€บ how-to-set-a-column-value-to-null-in-sql
How to Set a Column Value to Null in SQL? - GeeksforGeeks
You can set a column value to NULL using the SQL UPDATE statement. Through the UPDATE statement, existing records in a table can be changed.
Published ย  July 23, 2025
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_isnull.asp
SQL IFNULL(), ISNULL(), COALESCE(), and NVL() Functions
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Certificate SQL Training ... Suppose that the "UnitsOnOrder" column is optional, and may contain NULL values. ... In the example above, if any of the "UnitsOnOrder" values are NULL, the result will be NULL.
๐ŸŒ
Quora
quora.com โ€บ What-is-the-command-to-insert-null-values-in-SQL-fields
What is the command to insert null values in SQL fields? - Quora
Answer (1 of 11): SQL INSERT statement is used to insert new records into table. NULL keyword represents undefined value of a column belonging to database table. According to description as mentioned into above question SQL insert statement should not be executed to insert null values into tabl...
๐ŸŒ
Quora
quora.com โ€บ How-do-you-add-null-values-in-SQL
How to add null values in SQL - Quora
Answer (1 of 3): NULL values are handled differently depending on whether they are in the context of a tuple or a set. In the case of a tuple: (e.g. 1 + NULL), the result is always NULL. This is because if any part of a tuple is missing or unknown then the entire tuple cannot be known and hence m...