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 ;