Here is a table called posts_votes
id|discussion_id|post_id|user_id|vote_sign|
__________________________________________
1 | 1 | 1 | 1 | 1 |
2 | 1 | 1 | 2 | -1 |
3 | 1 | 2 | 3 | 1 |
4 | 1 | 2 | 4 | 1 |
5 | 2 | 3 | 1 | -1 |
6 | 2 | 4 | 2 | 1 |
I want to create a view with theses results:
discussion_id|post_id|score
1 | 2 | 2
2 | 4 | 1
With :
- post_id is the post with best score
- score is SUM(vote_sign)
I'm torturing my mind with group by and having max but I find no way to do it.. =(
If somebody has an idea...
Thanks ;)