JOE SKEET
JOE SKEET

Reputation: 8118

invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause

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

why am i getting this error

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.

Upvotes: 3

Views: 4510

Answers (2)

user536158
user536158

Reputation:

Hi herrow To solve this problem you need to replace select [finalConc] ,[rowid] from qvalues with select [finalConc] ,Count([rowid]) from qvalues

Upvotes: 0

Mark Byers
Mark Byers

Reputation: 839224

The error message is self-explanatory - you need to use an aggregate function:

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

Upvotes: 4

Related Questions