Hi,
I have a table with a list of votes.
Each vote has an item id (the item that the votes refers to) and a value (either 1 or -1).
I want to select all votes, group by item_id, and count all values together.
For example:
There's 51 votes for item_id=1 with value=1
There's 50 votes for item_id=1 with value=-1
There's 5 votes for item_id=2 with value=1
There's 2 votes for item_id=2 with value=-1
There's 4 votes for item_id=3 with value=-1
I want a query that gives me this:
Code:
item_id .. vote_sum
.. 2 ........ 3
.. 1 ........ 1
.. 3 ....... -4