Output
Chai 57
Chang 36
Aniseed Syrup 23
Chef Anton's Cajun Seasoning 75
Chef Anton's Gumbo Mix 21.35
Grandma's Boysenberry Spread 145
Uncle Bob's Organic Dried Pears 45
Northwoods Cranberry Sauce 46
Mishi Kobe Niku 126
Ikura 62
Above example describes use of addition operator in table fields. TotalProduct
displays each number of product we have bought from supplier by addition of UnitsInStock and
.
Example 3 : Add days to date and time values using addition operator.
SELECT ProductName, ShippedDate + 2
Output
ProductName ShippedDate
Scottish Longbreads 1998-02-25 00:00:00.000
Queso Cabrales 1998-02-25 00:00:00.000
Côte de Blaye 1998-02-25 00:00:00.000
Alice Mutton 1998-02-20 00:00:00.000
Sasquatch Ale 1998-02-20 00:00:00.000
Above example explains how we can use addition operator with date time type field.
Example 4 : Adding character and integer data types
SELECT Convert(VARCHAR,Quantity) + ' Quantity of ' + ProductName AS ProductList
Output
ProductList
18 Quantity of Scottish Longbreads
40 Quantity of Queso Cabrales
40 Quantity of Côte de Blaye
15 Quantity of Alice Mutton
10 Quantity of Sasquatch Ale
Above example illustrates addition operator can be used with different types of fields where Quantity field is of type double and ProductName is of type varchar.