MySQL Query Ranking
Posted
by
eft0
on Stack Overflow
See other posts from Stack Overflow
or by eft0
Published on 2011-02-23T15:22:07Z
Indexed on
2011/02/23
15:25 UTC
Read the original article
Hit count: 154
mysql
Hey there, I have this MySQL query for list a "Vote Ranking" for "Actions" and it work fine, but I want what the "id_user" doesn't repeat, like made a "DISTINCT" in this field.
SELECT
count(v.id) votos,
v.id_action,
a.id_user,
a.id_user_to,
a.action,
a.descripcion
FROM votes v, actions a WHERE v.id_action = a.id GROUP BY v.id_action ORDER BY votos DESC
The result:
votes act id_user
3 3 745059251
2 20 1245069513
2 23 1245069513
2 26 100000882722297
2 29 1245069513
2 44 1040560484
2 49 1257441644
2 50 1040560484
The expected result
votes act id_user
3 3 745059251
2 20 1245069513
2 26 100000882722297
2 44 1040560484
2 49 1257441644
2 50 1040560484
Thanks in advanced!
© Stack Overflow or respective owner