[英]invalid : aggregate function or the GROUP BY clause
Hey guys I can't seem to figure out what I'm doing wrong here. 嗨,我似乎无法弄清楚我在做什么错。 I'm quite new to SQL so I can't wrap my head around this. 我对SQL还是很陌生,所以我无法解决这个问题。 Any help would be great! 任何帮助将是巨大的!
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%'
You forgot the group by clause: 您忘记了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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.