既然我有一个多行的表格,是时分入手下手实行了。(一旦新列ExtendedAmount被盘算,其值会主动移植。)最后,我想用OrderID盘算ExtendedAmount列的总数。我创建一个视图,如列表B所示。
以下为援用的内容:
USE[Northwind_New]
GO
/******Object:?View[dbo].
[OrderDetailsSumByOrderID_vue]ScriptDate:08/23/200616:31:18******/
SETANSI_NULLSON
GO
SETQUOTED_IDENTIFIERON
GO
CREATEVIEW[dbo].[OrderDetailsSumByOrderID_vue]
AS
SELECTTOP100PERCENTOrderID,
SUM(ExtendedAmount)ASTotalAmount
FROM?dbo.OrderDetails_New
GROUPBYOrderID
ORDERBYOrderID