Using this statement:
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)
This error occurs:
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'.
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)