ORA-00937: 不是单组组函数
SELECT MIN(retail)
FROM books
WHERE category = 'COMPUTER'
工作正常,但是当我在选择中包含标题时,例如:
SELECT MIN(retail), title
FROM books
WHERE category = 'COMPUTER'
它不工作。为什么?如何让它发挥作用?
SELECT MIN(retail)
FROM books
WHERE category = 'COMPUTER'
works fine, but when I include title in select like:
SELECT MIN(retail), title
FROM books
WHERE category = 'COMPUTER'
it doesn't. Why? How to make it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
里斯的答案是正确的,如果这就是您的意思,但您可能想要
title
(s) whereretail=MIN(retail)
,并且该措辞建议如何得到答案:为了减少重复,您可以使用
WITH
子句(如果您使用的是最新版本的 SQL):我用来确认语法的示例。
Rhys's answer is correct, if that is what you mean, but you might have wanted the
title
(s) whereretail=MIN(retail)
, and that wording suggests how to get that answer:To reduce duplication you can use a
WITH
clause (if you're using a recent version of SQL):Sample I used to confirm syntax.
MIN 适用于一组记录,因此您需要告诉它您指的是哪组记录。
如果您的意思是为每个标题显示最低零售量,那么您需要:
MIN applies to a group of records, so you need to tell it which group of records you mean.
If you mean for each title, show the minimum of retail, then you need: