FLOOR (Transact-SQL)

適用于: Microsoft Fabric 中 Microsoft Fabric 倉儲中的 SQL Server Azure SQL 資料庫 Azure SQL 受控執行個體 Azure Synapse Analytics Analytics Platform System (PDW) SQL 分析端點

傳回小於或等於指定數值運算式的最大整數。

Transact-SQL 語法慣例

Syntax

FLOOR ( numeric_expression )  

注意

若要檢視 SQL Server 2014 (12.x) 和舊版的 Transact-SQL 語法,請參閱 舊版檔

引數

numeric_expression
這是精確數值或近似數值資料類型類別目錄的運算式。

傳回型別

傳回類型取決於numeric_expression 輸入類型:

輸入類型 傳回類型
floatreal float
decimal(p, s) decimal(38, s)
intsmallinttinyint int
bigint bigint
moneysmallmoney money
bit float

如果結果不符合傳回型別,就會發生算術溢位錯誤。

範例

下列範例會利用 FLOOR 函數來顯示正數、負數和貨幣值。

SELECT FLOOR(123.45), FLOOR(-123.45), FLOOR($123.45);  

結果是計算值的整數部分,與 numeric_expression 具有相同的資料類型。

---------      ---------     -----------  
123            -124          123.0000     

範例:Azure Synapse Analytics 和 Analytics Platform System (PDW)

下列範例會使用 FLOOR 函式來顯示正數、負數和值。

SELECT FLOOR(123.45), FLOOR(-123.45), FLOOR($123.45);  

結果是計算值的整數部分,與 numeric_expression 具有相同的資料類型。

-----   ---------    -----------  
 
123     -124         123

另請參閱

數學函數 (Transact-SQL)