嘿伙计们,我似乎无法弄清楚我在这里做错了什么。我对SQL很陌生,所以我无法解决这个问题。任何帮助都会很棒!
SELECT PC.Name AS [ProductCategoryName]
, MIN(PCH.StandardCost) AS MinStandardCost
, AVG(PCH.StandardCost) AS AverageStandardCost
, MAX(PCH.StandardCost) AS MaxStandardCost
FROM ProductCategory PC
INNER JOIN Product P ON (PC.ProductCategoryID = P.ProductCategoryID)
INNER JOIN ProductCostHistory PCH ON ( P.ProductID = PCH.ProductID)
WHERE PC.Name LIKE '%Bike%'
答案 0 :(得分:0)
你忘记了group by子句:
SELECT PC.Name AS [ProductCategoryName]
, MIN(PCH.StandardCost) AS MinStandardCost
, AVG(PCH.StandardCost) AS AverageStandardCost
, MAX(PCH.StandardCost) AS MaxStandardCost
FROM ProductCategory PC
INNER JOIN Product P ON (PC.ProductCategoryID = P.ProductCategoryID)
INNER JOIN ProductCostHistory PCH ON ( P.ProductID = PCH.ProductID)
WHERE PC.Name LIKE '%Bike%'
group by PC.NAME