【发布时间】:2016-10-28 20:16:29
【问题描述】:
我的数据库包含产品和饰面列表。我已经能够成功地平均每个完成选项的价格,但我只想显示价格最低的选项。
这是我的数据样本。
表 1 - product_t
ProductID ProductLineID ProductDescription ProductFinish ProductStandardPrice ProductOnHand
1 1 "Cherry End Table" Cherry 175.00 0
2 1 "Birch Coffee Tables" Birch 200.00 0
3 1 "Oak Computer Desk" Oak 750.00 0
4 1 "Entertainment Center" Cherry 1650.00 0
此查询会生成每个可用产品饰面的列表以及具有饰面的商品的平均价格。
SELECT ProductFinish, AVG(ProductStandardPrice) as AveragePrice
FROM product_t
WHERE ProductFinish IS NOT NULL
GROUP BY ProductFinish;
但是,我只想显示此查询产生的最低价格。我尝试了这个查询,但它不会执行。
SELECT ProductFinish, MIN (AVG(ProductStandardPrice)) as AveragePrice
FROM product_t
WHERE ProductFinish IS NOT NULL
GROUP BY ProductFinish;
提前感谢您的帮助。非常感谢。
【问题讨论】:
-
请标记正在使用的 dbms。