Help with grouped query
Posted on 2004-11-03
I have a query that I need to add a column to, but when I do the error I receive asks me to include it in the grouped section which then messes up my output. Here is my query. It is outputing survey results.
<cfquery datasource="#DataTables#" name="getReplies">
SELECT sum(poll_Replies.numReply) AS totalreplies, poll_Replies.answerID, poll_question.questionID, poll_question.question, poll_question.qtype, poll_choices.answerText, poll_Replies.textReply, poll_Replies.textReply_2
FROM poll_Replies INNER JOIN
poll_Choices ON poll_Replies.answerID = poll_Choices.answerID INNER JOIN
poll_question ON poll_Choices.questionID = poll_question.questionID
WHERE (poll_Replies.answerID IN
WHERE questionid IN
WHERE pollID = #getPoll.pollID#)))
GROUP BY poll_Replies.answerID, poll_question.questionID, poll_question.question, poll_choices.answerText, poll_question.qtype, poll_Replies.textReply, poll_Replies.textReply_2
The column I needed to add was (poll_Replies.textReply_2). If I don't add it to the grouped line it gives me this error:
[Macromedia][SQLServer JDBC Driver][SQLServer]Column 'poll_Replies.textReply_2' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
But like i said, this messes up my output. Is there a way to reformat this so that I do not have to include that in my grouped by line?