22,210
社区成员
发帖
与我相关
我的任务
分享
CREATE VIEW dbo.Invoice_D_ViewSum WITH SCHEMABINDING
AS
Select DType as Type, DocSigNo as ShipSigNo, IndentID, ChartID,
Sum(Amt) as Amt,
/*注意这里,在插入数据的时候就已经自动汇总了,你查询时只是读取这个已经完成了的汇总表*/ count_big(*) as cnt
from dbo.Invoice_D
Group by DType, DocSigNo, IndentID, ChartID
GO
CREATE UNIQUE CLUSTERED INDEX idx_Type ON dbo.Invoice_D_ViewSum(Type,ShipSigNo,IndentID,ChartID );