SELECT [SalesOrderID]
,[OrderDate]
,[CustomerID]
,[SalesPersonID]
,[SubTotal]
,[TaxAmt]
,(SELECT COUNT(*)FROM [AdventureWorks2008R2].[Sales].[SalesOrderHeader] B
WHERE A.CustomerID = B.CustomerID) 客户总单数
FROM [AdventureWorks2008R2].[Sales].[SalesOrderHeader] A
order by CustomerID,SalesOrderID