with cte as ( select p.OwnerUserId, p.Id, p.ViewCount, RA...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Coffee Meta

Q&A about the site for people interested in all aspects of producing and consuming coffee

with cte as (
select
  p.OwnerUserId,
  p.Id,
  p.ViewCount,
  RANK() OVER (partition by p.OwnerUserId order by p.ViewCount desc, p.Id) as rank
from
  Posts p
where
  p.PostTypeId = 1
  and p.OwnerUserId is not null
  )
select
  c.OwnerUserId,
  c.Id,
  c.ViewCount
from
  cte c
where
  rank <= 2
;

Enter Parameters

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