The SQL Add (+), or the Addition operator is used to add to numbers and days to a date. In this video, you will see how to use it inside of SQL Server Management Studio.
I first want to take a look at the Employee table in the SQL Training Online Simple Database.
select * from employee
We can add those two columns together by using the plus sign (+), or addition operator in SQL:
,commision ,salary + commision
But, since there can be nulls in the commission column, we need to handle that with the isnull function:
,isnull(commision,0) as commision
,salary + isnull(commision,0) as total_compensation
Next, I want to show you how to add with a datetime.
When you use the SQL Add operator, SQL Server will actually add the number in days.
Here is an example:
,hire_date + 2 as training_date
Let me know what you think by commenting or sharing on twitter, facebook, google+, etc.