title

0

Please login or register to vote for this query.

(click on this box to dismiss)

Science Fiction and Fantasy Meta

Q&A about the site for science fiction and fantasy enthusiasts

/*decile of posts count by user_id

select userid, ntile(10) over (order by no_posts)
from 
  (select top(100) userid, count(postid) as 'no_posts'
  from comments
  where year(creationdate) = 2021
  group by userid
  order by count(creationdate) desc) a
  
 */
 
 select a.userid, a.last_post, b.text
 from 
 (select userid, max(creationdate) as 'last_post'
 from comments 
 group by userid) as a
 join comments as b
 on 
 a.userid = b.userid
 and a.last_post = b.creationdate
 order by last_post desc

Enter Parameters

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