In AdventureWorks2012 database, I have to use the Sales.SalesPerson
, Sales.SalesOrderHeader
, Sales.SalesOrderDeatil
, and Production.Product
tables listing all Distinct products that have ProductID
and Name which are sold in Territory 5.
Below is my attempted answer.
SELECT DISTINCT
sod.ProductID,
p.Name
FROM
Sales.SalesPerson SP,
Sales.SalesOrderHeader SOH,
Sales.SalesOrderDetail SOD,
Production.Product P
WHERE
SP.BusinessEntityID = soh.SalesOrderID AND
soh.SalesOrderID = sod.SalesOrderID AND
sod.SalesOrderID = p.ProductID
The query executed successfully, but 0 rows were affected. What am I doing wrong?
i'm guessing this, orderid = productid? probably mistake, maybe you wanted