Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

傳回查詢中指定欄位中所包含一組值的總和。

語法

加總 ( expr )

expr 佔位元代表 字串運算式 識別包含您要新增之數值數據的欄位,或使用該欄位中的數據執行計算的運算式。 expr 中的操作數可以包含數據表字段的名稱、常數或函數 (可以是固有的或使用者定義的,但不能包含其中一個其他 SQL 匯總函數) 。

註解

Sum 函數會加總欄位中的值。 例如,您可以使用 Sum 函數 來決定運費的總成本。

Sum 函數會忽略包含 Null 欄位的記錄。 下列範例示範如何計算 UnitPrice 和 Quantity 字段產品的總和:

SELECT Sum(UnitPrice * Quantity) AS [Total Revenue]
FROM [Order Details];

您可以在查詢表示式中使用 Sum 函數。 您也可以在QueryDef 物件的 SQL 屬性或以 SQL 查詢建立 Recordset 時使用此運算式。

使用查詢

計算 SQL 函數中的欄位

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×