title

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping

Q&A for gardeners and landscapers

/*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 top (50) a.userid, max(a.creationdate) as 'last_post', b.text
 from comments a
 
 join comments b 
 on a.userid = b.userid 
 and a.creationdate = b.creationdate
 
 group by a.userid, b.text

Enter Parameters

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