簡體   English   中英

invalid:聚合函數或GROUP BY子句

[英]invalid : aggregate function or the GROUP BY clause

嗨,我似乎無法弄清楚我在做什么錯。 我對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%'

您忘記了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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM