gpt4 book ai didi

sql - ORA-00937 : not a single-group group function

转载 作者:行者123 更新时间:2023-12-04 10:11:49 24 4
gpt4 key购买 nike

SELECT MIN(retail)
FROM books
WHERE category = 'COMPUTER'

工作正常,但是当我在选择中包含标题时:
SELECT MIN(retail), title
FROM books
WHERE category = 'COMPUTER'

它没有。为什么?如何使它工作?

最佳答案

Rhys 的回答是正确的,如果这就是你的意思,但你可能想要 title (s) 哪里 retail=MIN(retail) ,并且该措辞表明如何获得该答案:

SELECT title, retail
FROM books
WHERE category = 'COMPUTER'
AND retail = (SELECT MIN(retail) FROM books WHERE category = 'COMPUTER')
为了减少重复,您可以使用 WITH子句(如果您使用的是最新版本的 SQL):
;WITH ComputerBooks AS (
SELECT title, retail
FROM books
WHERE category = 'COMPUTER')
SELECT title, retail
FROM ComputerBooks
WHERE retail = (SELECT MIN(retail) FROM ComputerBooks)
Sample I used to confirm syntax.

关于sql - ORA-00937 : not a single-group group function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5591154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com