*(乘法)(Transact SQL)* (Multiplication) (Transact-SQL)

适用对象: 是SQL Server 是Azure SQL 数据库 是Azure Synapse Analytics (SQL DW) 是并行数据仓库 APPLIES TO: yesSQL Server yesAzure SQL Database yesAzure Synapse Analytics (SQL DW) yesParallel Data Warehouse

两个表达式相乘(算术乘法运算符)。Multiplies two expressions (an arithmetic multiplication operator).

主题链接图标 TRANSACT-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

expression * expression  

参数Arguments

expressionexpression
数值数据类型类别中任意一种数据类型(datetimesmalldatetime 数据类型除外)的任意有效表达式Is any valid expression of any one of the data types of the numeric data type category, except the datetime and smalldatetime data types.

结果类型Result Types

返回优先级较高的参数的数据类型。Returns the data type of the argument with the higher precedence. 有关详细信息,请参阅数据类型优先级 (Transact-SQL)For more information, see Data Type Precedence (Transact-SQL).

示例Examples

以下示例在 Product 表中检索所有山地自行车的产品标识号、名称、价目表价格以及新的价目表价格。The following example retrieves the product identification number, name, the list price and the new list price of all the mountain bicycles in the Product table. 新标价是通过使用 * 算术运算符将 ListPrice 乘以 1.15 计算得出的。The new list price is calculated by using the * arithmetic operator to multiply ListPrice by 1.15.

-- Uses AdventureWorks  
  
SELECT ProductID, Name, ListPrice, ListPrice * 1.15 AS NewPrice  
FROM Production.Product  
WHERE Name LIKE 'Mountain-%'  
ORDER BY ProductID ASC;  
GO  

示例:Azure Synapse Analytics (SQL DW)Azure Synapse Analytics (SQL DW)并行数据仓库Parallel Data WarehouseExamples: Azure Synapse Analytics (SQL DW)Azure Synapse Analytics (SQL DW) and 并行数据仓库Parallel Data Warehouse

以下示例在 dimEmployee 表中检索员工的姓氏和名字,并计算每位员工的 VacationHours 的薪水。The following example retrieves the first and last name of employees in the dimEmployee table, and calculates the pay for VacationHours for each..

-- Uses AdventureWorks  
  
SELECT FirstName, LastName, BaseRate * VacationHours AS VacationPay  
FROM DimEmployee  
ORDER BY lastName ASC;  

另请参阅See Also

数据类型 (Transact-SQL) Data Types (Transact-SQL)
表达式 (Transact-SQL) Expressions (Transact-SQL)
内置函数 (Transact-SQL) Built-in Functions (Transact-SQL)
运算符 (Transact-SQL) Operators (Transact-SQL)
SELECT (Transact-SQL) SELECT (Transact-SQL)
WHERE (Transact-SQL) WHERE (Transact-SQL)
*=(乘法赋值)(Transact-SQL) *= (Multiplication Assignment) (Transact-SQL)
复合运算符 (Transact-SQL)Compound Operators (Transact-SQL)