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.

您可以在 SQL 匯總函數中使用 字串運算式 自變數,對字段中的值執行計算。 例如,您可以將域值乘以分數,以計算 (百分比,例如附加稅或營業稅) 。

下表提供Northwind.mdb資料庫中 [訂單] 和 [訂單詳細數據] 數據表字段的計算範例。

計算

範例

新增數位至欄位

Freight + 5

將欄位中的數位相減

Freight - 5

將欄位乘以數位

UnitPrice * 2

將欄位除以數位

Freight / 2

新增一個字段至另一個字段

UnitsInStock + UnitsOnOrder

從另一個字段減去一個字段

ReorderLevel - UnitsInStock


下列範例會計算Northwind.mdb資料庫中所有訂單的平均折扣金額。 它會將 [單價] 和 [折扣] 字段中的值相乘,以決定每筆訂單的折扣金額,然後計算平均值。 您可以在 Visual Basic 程式代碼的 SQL 語句中使用此表示式:

SELECT Avg(UnitPrice * Discount) AS [Average Discount] FROM [Order Details];



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!

×