Window Function and Subquery

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

select * from (
  select owneruserid,
         viewcount,
         ownerdisplayname,
         month(creationdate) as months,
         row_number() over (partition by month(creationdate) order by viewcount desc) as monthly_rank
  from posts) ranked
where monthly_rank <=3
order by months asc

Enter Parameters

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