非布尔类型的表达
使用此语句:
select * from qvalues where rowid ,name,compound in (
select rowid,name,compound from qvalues where rowid in (select rowid from batchinfo where instrument='tf1')
group by rowid,name,compound
having COUNT(*)>1
)
group by rowid,name,compound
having rid=min(rid)
出现这个错误:
消息 4145,级别 15,状态 1,第 3 行在预期条件的上下文中指定的非布尔类型的表达式,靠近 ','.Msg 156, Level 15, State 1, Line 8关键字group"附近的语法不正确.
Msg 4145, Level 15, State 1, Line 3 An expression of non-boolean type specified in a context where a condition is expected, near ','. Msg 156, Level 15, State 1, Line 8 Incorrect syntax near the keyword 'group'.
这个SQL语句有什么问题?我需要在 have min(rid)
表中找到这三个字段的所有出现.
What is wrong with this SQL statement? I need to find all the occurrences of those three fields in the table having min(rid)
.
更新使用此查询,外部选择不起作用.我做错了什么?
Update Using this query, the outer select is not working. What am I doing wrong?
select * from qvalues where rid not in (
select q.rowid, q.name, q.compound, min(q.rid)
from qvalues q
inner join batchinfo b
on q.rowid = b.rowid
and b.instrument = 'tf1'
group by q.rowid, q.name, q.compound
having count(*) > 1)
推荐答案
我认为这与您要实现的目标相同.
I think this is equivalent to what you're trying to achieve.
select min(q.rid)
from qvalues q
inner join batchinfo b
on q.rowid = b.rowid
and b.instrument = 'tf1'
group by q.rowid, q.name, q.compound
having count(*) > 1
相关文章