with cte as ( select p.OwnerUserId, max(coalesce(p.ViewCo...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Science Fiction and Fantasy

Q&A for science fiction and fantasy enthusiasts

with cte as (
select
  p.OwnerUserId,
  max(coalesce(p.ViewCount, 0)) as max_views
from
  Posts p
where
  p.PostTypeId = 1
  and p.OwnerUserId is not null
group by
  p.OwnerUserId
)
select
  q.OwnerUserId,
  q.Id,
  q.ViewCount
from
  Posts q
inner join
  cte c
on
  q.OwnerUserId = c.OwnerUserId
  and q.ViewCount = c.max_views
order by
  1,3 desc

Enter Parameters

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