I have a table in SQL, where users can answer many times (the same users and different users). I want to count how many true or false values there are.
For example, like user 1 has 5 rows in my table, 3 times true, and 2 times false and user 9 has got 10 true and 1 false like that but I would not know what user numbers.
I would like output like
User 1 – 5x True 1x False, User 4 1x True 3x False etc. But I would not know what user and the user list can grow.
there is a simple (not recommended) solution using a loop:
you would have an array holding positive answers per user and total answers per users which you can then use to calculate negative answers
the recommended solution is to use a group by sql statement that gives you all the calculated information.
see: http://dev.mysql.com/tech-resources/articles/wizard/page3.html