SQL Group BY error

houssam_ballout

New Member
hello all,
I am trying this sql:
select count(OptionNb),comments from tblanswer where idQuestion = $idQuestion And OptionNb = 'option$i'
and I got this error
Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

How could I solve it ?
Thanks in advance
 
You can't select a count and a normal field without grouping on the normal field.

To make that exact query work you would need to do this:

select count(OptionNb),comments from tblanswer where idQuestion = $idQuestion And OptionNb = 'option$i' group by comments

I don't know if that will produce the results you are looking for as I'm not sure what you are trying to accomplish but it will get rid of that error.
 
Back
Top