SELECT votes object_id COUNT as score FROM votes INNER JOIN blog_post

1
2
3
4
5
6
7
8
SELECT votes.object_id, COUNT(*) as score
FROM votes
INNER JOIN blog_post
ON votes.object_id = blog_post.id
WHERE CURRENT_DATE -7 < blog_post.date and blog_post.date < CURRENT_TIMESTAMP
GROUP BY object_id
ORDER BY score
LIMIT 10;