SQL server2000里northwind系统视图,希望新建一个视图可以显示每个customer每年的消费情况,求代码,里面有个summary of sales by year的视图 就是照着那个加上顾客的名字 然后把每年的价格合起来,但是是每年的消费情况总和而不是每天每天的列出来,高手在民间,谢谢大家了 求代码
------解决方案--------------------
好像这样就行了吧。。[code=sql]SELECT dbo.Orders.ShippedDate ,[/code]
dbo.Customers.ContactName ,
SUM(dbo.[Order Subtotals].Subtotal) [Total]
FROM dbo.Orders
INNER JOIN dbo.[Order Subtotals] ON dbo.Orders.OrderID = dbo.[Order Subtotals].OrderID
INNER JOIN dbo.Customers ON dbo.Orders.CustomerID = dbo.Customers.CustomerID
WHERE ( dbo.Orders.ShippedDate IS NOT NULL )
GROUP BY dbo.Orders.ShippedDate ,
dbo.Customers.ContactName