非布尔类型的表达

时间:2023-02-07
本文介绍了非布尔类型的表达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

使用此语句:

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

这篇关于非布尔类型的表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:从UTC时间计算特定时区的时间 下一篇:组合子查询中的行的 Select 语句(枢轴)

相关文章

最新文章