Jon, there is only one table. There isn't one table for the responses and one 
for the questions. 


> I could be wrong, but it seems like you might be making it harder than 
> it needs to be from the query side, if you are looking for totals of 
> responses by question.  You might be able to just use a GROUP BY 
> clause to handle it.
> 
> SELECT        questions.id,questions.question,
>               count(r.disagree) as disagreed,  /*Disagreed Count*/
>               count(r.agree) as agreed, /*Agreed Count*/
>               count(r.neither) as neutral, /*Neutral Count*/
>               count(r.strongly_agree) as strongly_agreed, /*SA Count*/
>               count(r.strongly_disagree) as strongly_disagreed, /*SD Count*/
>               (SELECT count(*) FROM responses r2  /*No Response Count*/
>                       where question_id = questions.id 
>                       AND r2.agree IS NULL 
>                       AND r2.disagree IS NULL
>                       AND r2.neither IS NULL
>                       AND r2.strongly_agree IS NULL
>                       AND r2.strongly_disagree IS NULL) as no_response
> FROM questions
> INNER JOIN responses r on r.question_id = questions.id
> GROUP by questions.id,questions.question
> 
> Note the following was tested on MySQL and I’m sure there’s an SQL 
> ninja that could probably find a better way to aggregate the 
> sub-select.
> 
> HTH,
> Jon
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359820
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to