sql - 如何在sql中使用带有where条件的avg?
问题描述
我想选择高于平均价格的产品。这是我的 SQL:SELECT ProductName, Price FROM Products where Price >= AVG(Price);
它说平均值是错误的......任何人都可以帮助我吗?
解决方案
试试看:
SELECT ProductName, Price
FROM Products
where Price >= (select avg(price) from Products)
推荐阅读
- android - 在 Fragment 中,单击 listView 项以打开新活动并将值传递给其他活动
- javascript - 如何在 Firestore 中订购文档?
- android - Google 登录 - 关闭登录对话框时出现 ApiException 12501
- ios - iOS:在 touchesEnded 完成后删除数组中的最后一个图像
- c# - 删除和克隆存储库后丢失 nuget 引用
- excel - 需要相对于今天的日期计算 Excel 中的某些文本,每个单元格中都有大量可变数据
- makefile - gnu make:为什么叫“顶级”目标?
- virtual-machine - Genymotion 启动失败(vrc=VERR_SUPDRV_COMPONENT_NOT_FOUND,rc=E_FAIL (0X80004005))
- linux - 避免在 bash 中使用数组进行通配符扩展
- c# - C# 多部分响应构建