with averagevc as ( select users.id as id, avg(posts.view...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

with averagevc as (
select users.id as id, 
avg(posts.viewcount) as average_viewcount
from users
left join posts
on users.id = posts.owneruserid
group by users.id)

select 
users.id,
posts.viewcount,
average_viewcount

from users
left join posts
on users.id = posts.owneruserid
left join averagevc
on users.id = averagevc.id

where posts.viewcount > average_viewcount

Enter Parameters

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