Multiply operator is used to perform multiplication of any numeric type fields except datetime in sql server.
Syntax of * ( Multiply ) Operators :
expression * expression
Expression is any valid expression of the numeric data type except datetime data type in sql server.
Example of * ( Multiply ) Operator :
Example 1 : Displays use of multiplication for numeric numbers.
SELECT 3*4
Output
12
Above example explains how can we use multiplication operator for numeric numbers.
Example 2 : Example of multiplying digit with table field.
SELECT ProductName, UnitPrice * 2 AS Price
FROM Products
Output
ProductName Price
Chai 36.00
Chang 38.00
Aniseed Syrup 20.00
Chef Anton's Cajun Seasoning 44.00
Chef Anton's Gumbo Mix 42.70
Above example displays how can we use multiplication operator with table field UnitPrice and numeric number 2.
Example 3 : Example of multiplying 2 fields of tables.
SELECT ProductName, UnitsInStock * UnitPrice AS TotalCostOfEachProduct
FROM Products
Output
ProductName TotalCostOfEachProduct
Chai 702
Chef Anton's Cajun Seasoning Chef Anton's Gumbo Mix 0
Above example displays total cost of each product by multiplying UnitInStock and UnitPrice fields of products table.