with parent(id, parentid, body, owneruserid, lasteditorus...

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 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)
, answer(id,sum2) as
(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)
, question(id,sum1) as (
select p.id,
sum(CASE
WHEN u.reputation > 500 THEN 1
    END) as rm
from parent p join users u on u.id = p.owneruserid or u.id = p.lasteditoruserid
group by p.id)

select (q.sum1 + a.sum2) as total
from question q, answer a;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results