Ошибочные результаты из-присоединяйтесь
I'm using the Adventureworks 2014 database and am trying to achieve an output that displays sales on the bike product category by region I've created an inner join using 4 tables to achieve this but when I execute it it just looks as thought the figures are copied, it doesn't look like they're influencing each other e.g the sales YTD column is exactly the same for all of the rows Below is the code I used <pre>select p.[ProductSubcategoryID],s.[TerritoryID],d.[ProductID], r.[CountryRegionCode], r.SalesYTD, r.SalesLastYear from [Sales].[SalesOrderDetail] as d, [Sales].[SalesOrderHeader] as s, [Production].[Product] as p, [Sales].[SalesTerritory] as r INNER JOIN [Production].[Product] ON [ProductID] = [ProductID] INNER JOIN [Sales].[SalesOrderHeader] ON [SalesOrderID] = [SalesOrderID]
Что я уже пробовал:
select p.[ProductSubcategoryID],s.[TerritoryID],d.[ProductID], r.[CountryRegionCode], r.SalesYTD, r.SalesLastYear from [Sales].[SalesOrderDetail] as d, [Sales].[SalesOrderHeader] as s, [Production].[Product] as p, [Sales].[SalesTerritory] as r INNER JOIN [Production].[Product] ON [ProductID] = [ProductID] INNER JOIN [Sales].[SalesOrderHeader] ON [SalesOrderID] = [SalesOrderID]