3
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.

JOE SKEET
  • 7,950
  • 14
  • 48
  • 64
  • possible duplicate of [Column "invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause"](http://stackoverflow.com/questions/18258704/column-invalid-in-the-select-list-because-it-is-not-contained-in-either-an-aggr) – Tanner Apr 29 '15 at 13:44

2 Answers2

4

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

SELECT
    [finalConc],
    MIN([rowid]) AS minRowId,
    MAX([rowid]) AS maxRowId
FROM ...
Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
0

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