Testing

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

--SELECT * FROM posthistory where userID = 4953620 and
--datepart(year,creationdate) = 2016


select datepart(year,ps.creationdate) Years, ps.userid,
    count(ps.userid) ActiveRevier from posthistory ps
    inner join posts p
    on ps.postid = p.id and p.posttypeid = 1 and p.acceptedAnswerId is not null
    and ps.userid is not null
    where datepart(year,ps.creationdate) =2017
    group by datepart(year,ps.creationdate), ps.userid
    having count(ps.userid) >= 5 
    union 
    select datepart(year,ps.creationdate) Years, ps.userid,
    count(ps.userid) ActiveRevier from posthistory ps
    inner join posts a
    on ps.postid = a.id and a.posttypeid = 2 and ps.userid is not null
    inner join posts q
    on a.parentid = q.id and q.acceptedAnswerId is not null
    where datepart(year,ps.creationdate) =2017
    group by datepart(year,ps.creationdate), ps.userid
    having count(ps.userid) >= 5
    
    --201649536207

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results