SELECT S.CustomerID, SO.SalesOrderNumber, SO.OrderDate, SO.TotalDue, S.Name AS Store,
A.City, SP.Name AS StateProvince, CR.Name AS CountryRegion, SC.ContactID As StoreContactID,
T.[Group] As TerritoryGroup, Year(SO.OrderDate) as Year
FROM Sales.Store AS S
JOIN Sales.CustomerAddress AS CA ON CA.CustomerID =S.CustomerID
JOIN Person.Address AS A ON A.AddressID = CA.AddressID
JOIN Person.StateProvince SP ON P.StateProvinceID = A.StateProvinceID
JOIN Person.CountryRegion CR ON CR.CountryRegionCode = SP.CountryRegionCode
JOIN Sales.SalesOrderHeader AS SO ON S.CustomerID = SO.CustomerID
JOIN Sales.StoreContact SC ON S.CustomerID = SC.CustomerID
JOIN Sales.Customer C on S.CustomerID = C.CustomerID
JOIN Sales.SalesTerritory T on C.TerritoryID = T.TerritoryID
ORDER BY S.CustomerID
执行产生这样的错误提示:
消息 4104,级别 16,状态 1,第 1 行
无法绑定由多个部分组成的标识符 "P.StateProvinceID"。
SP