Skip to content

Instantly share code, notes, and snippets.

@gmantri
Created May 26, 2020 07:44
Show Gist options
  • Save gmantri/c1aafdf437fda547d9f0c73dcc63af09 to your computer and use it in GitHub Desktop.
Save gmantri/c1aafdf437fda547d9f0c73dcc63af09 to your computer and use it in GitHub Desktop.
Select Users.Id,
Users.DisplayName,
Min(Posts.CreationDate) as FirstAnswerProvidedDate,
Max(Posts.CreationDate) as LastAnswerProvidedDate,
Count(Distinct(Posts.Id)) As AnswersProvided,
SUM(CASE WHEN Votes.VoteTypeId = 1 THEN 1 ELSE 0 END) AS AcceptedAnswers,
SUM(CASE WHEN Votes.VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes,
SUM(CASE WHEN Votes.VoteTypeId = 3 THEN 1 ELSE 0 END) AS Downvotes
From Users
Left Join Posts on Users.Id = Posts.OwnerUserId
Left Join Votes on Posts.Id = Votes.PostId
Where Posts.PostTypeId = 2 And Users.Id = <enter-your-user-id-here>
And (Posts.CreationDate >= '2020-05-01')
Group By Users.Id, Users.DisplayName
Order By AnswersProvided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment