我的sql看起来像这样,我只想显示价格高于平均值的商品
SELECT COUNT(Artikelnamn) AS 'Antal Artiklar',
FLOOR(SUM(Price)) AS 'Lagervärde',
FLOOR(MAX(Price)) AS 'Max',
FLOOR(MIN(Pris)) AS 'Min',
FLOOR(AVG(Price)) AS 'Genomsnitt'
FROM Artikel
GROUP BY Price HAVING Price > AVG(Price);
特别是GROUP BY
不起作用,我真的用Google搜索。
答案 0 :(得分:-1)
我不确定你要做什么,但如果你想: "价格高于平均水平的物品" 它会是:
SELECT * FROM Artikel WHERE price > SELECT AVG(price ) FROM Artikel;
或许你想做:
SELECT COUNT(Artikelnamn) AS 'Antal Artiklar',
FLOOR(SUM(Price)) AS 'Lagervärde',
FLOOR(MAX(Price)) AS 'Max',
FLOOR(MIN(Pris)) AS 'Min',
FLOOR(AVG(Price)) AS 'Genomsnitt' FROM Artikel
GROUP BY Price HAVING Price > SELECT AVG(price ) FROM Artikel;