WITH voted_posts AS( SELECT p.id, t.name, count(v.id) vot...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Physical Fitness

Q&A for physical fitness professionals, athletes, trainers, and those providing health-related needs

WITH voted_posts AS(
SELECT p.id,
       t.name,
       count(v.id) votes_cnt,
       RANK() OVER (
       PARTITION BY t.name
       ORDER BY count(v.id) DESC ) vote_rank
FROM posts p
JOIN votes v on p.id = v.postid
JOIN votetypes t on v.votetypeid = t.id and t.name in('UpMod', 'DownMod')
GROUP BY p.id, t.name
)
SELECT *
  FROM voted_posts
WHERE vote_rank <= 10;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results