I'm trying to do a query on SQL but I'm stuck!
I have two tables:
Table 1: Question
Table 2: Answer
For each question I can have one or more answers from different users but each user can comment one time.
When a user answers a question, he must choose one status to his answer:
1) Agree, 2) Disagree or 3) Discuss
So, the "Question" table has all the questions like this:
Id Question
1 q1
2 q2
3 q3
..and the "Answer" table has all the answers from the users, plus the FK from the "Question" table and a column with the status chosen by the user.
Id Answer IdQuestion Status
1 a1 1 1
2 a2 1 3
3 a3 2 2
4 a4 2 2
5 a5 3 1
What I need: I need to select all the questions AND I need to count all the questions that has different aswer's status.
Example:
Question 1 has two answers and the two answers has different status. I need to count or put a number just to know that this question has answers with diffent status.
Question 2 has two answers but all the answers has the same status. I don't need to count that.. or maybe put other number to differentiate from the questions that has answers with diffent status.
And the Questions that has only one answer I just select it normally.