gpt4 book ai didi

sql - 在选择列表中无效,因为它不包含在聚合函数或 GROUP BY 子句中

转载 作者:行者123 更新时间:2023-12-01 13:03:27 25 4
gpt4 key购买 nike

use qcvalues_test
go

select [finalConc]
,[rowid] from qvalues where rowid in (select rowid from batchinfo where instrument = 'TF1')
and name='qc1'
and compound='etg'
group by finalConc
having COUNT(rowid)=2

为什么会出现这个错误

Msg 8120, Level 16, State 1, Line 3 Column 'qvalues.rowid' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

最佳答案

错误消息不言自明 - 您需要使用 aggregate function :

SELECT
[finalConc],
MIN([rowid]) AS minRowId,
MAX([rowid]) AS maxRowId
FROM ...

关于sql - 在选择列表中无效,因为它不包含在聚合函数或 GROUP BY 子句中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4393043/

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