SQL SUM and COUNT returning wrong values
===

I found a bunch of similar questions but nothing worked for me, or I am too stupid to get how to do it right.
The visit count works fine if I use **COUNT(DISTINCT visits.id)** but then the vote count goes totally wrong - it displays a value 3 to 4 times larger than it should be.

So this is the query

    SELECT SUM(votes.rating), COUNT(visits.id)
    FROM topics
    LEFT JOIN visits ON ( visits.content_id = topics.id )
    LEFT JOIN votes ON ( votes.content_id = topics.id )
    WHERE topics.id='1'
    GROUP BY topics.id

The **votes** table looks like this

    id int(11) | rating tinyint(4) | content_id int(11) | uid int(11)


**visits** table

    id int(11) | content_id int(11) | uid int(11)


**topics** table

    id int(11) | name varchar(128) | message varchar(512) | uid int(11)

help?