Q&A about the site for serious players and enthusiasts of poker
with parent(id, parentid, body, owneruserid, lasteditoruserid) as ( select p.id, p.parentid, p.body, p.owneruserid, p.lasteditoruserid from posts p where p.id = 580639) select p.id, sum(CASE WHEN u.reputation > 500 THEN 1 END) as rm from parent p join posts p2 on p2.parentid = p.id join users u on u.id = p2.owneruserid or u.id = p2.lasteditoruserid group by p.id; with parent(id, parentid, body, owneruserid, lasteditoruserid) as ( select p.id, p.parentid, p.body, p.owneruserid, p.lasteditoruserid from posts p where p.id = 580639) select p.id, count(p2.id) from parent p join users u on u.id = p.owneruserid or u.id = p.lasteditoruserid join posts p2 on p2.parentid = p.id group by p.id;