People helped - By user and date range

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu

Q&A for Ubuntu users and developers

Select Sum(Cast(ViewCount as BigInt)) as PeopleHelped
  From Posts pmd
 Where pmd.Id In (Select ParentId
                        From Posts
                       Where PostTypeId = 2
                         And CreationDate >= '##StartDate##'
                         And CreationDate <= '##EndDate##'
                         And Id in (select AcceptedAnswerId from Posts)
                         And OwnerUserId = ##UserId##
                      Union
                      Select ParentId
                        From Posts
                       Where PostTypeId = 2
                         And CreationDate >= '##StartDate##'
                         And CreationDate <= '##EndDate##'
                         And Score > 5
                         And OwnerUserId = ##UserId##
                      Union
                      Select a.ParentId
                        From Posts a
                             Join Posts q On a.ParentId = q.Id
                       Where a.PostTypeId = 2
                         And a.CreationDate >= '##StartDate##'
                         And a.CreationDate <= '##EndDate##'
                         And a.Score > 0.20 * (select sum(Score) from Posts where ParentId=q.Id)
                         And a.Score > 0
                         And a.OwnerUserId = ##UserId##
                      Union
                      Select x.ParentId
                        From (Select a.ParentId, Rank() Over(Partition By a.ParentId Order By ta.Score Desc) AnswerRank
                                From Posts a
                                     Join Posts ta On ta.ParentId = a.ParentId
                               Where a.PostTypeId = 2
                                 And a.CreationDate >= '##StartDate##'
                                 And a.CreationDate <= '##EndDate##'
                                 And a.Score > 0
                                 And a.OwnerUserId = ##UserId##) x
                      Where AnswerRank <= 3
                  );

Select count(a.ParentId) as AnswerCount, sum(q.ViewCount) 
                        From Posts a
                        Join Posts q On a.ParentId = q.Id
                       Where a.PostTypeId = 2
                         And a.CreationDate >= '##StartDate##'
                         And a.CreationDate <= '##EndDate##'
                         And a.OwnerUserId = ##UserId##

Enter Parameters

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