Created
January 19, 2014 13:38
-
-
Save chadcooper/8505127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- All my answers | |
-- All my answers on the site | |
DECLARE @UserId int = ##UserId## | |
DECLARE @Year int = ##Year## | |
SELECT | |
a.Id AS [Post Link], | |
CASE WHEN q.AcceptedAnswerId=a.Id THEN 'Accepted' END AS Accepted, | |
CASE WHEN q.OwnerUserId=a.OwnerUserId THEN 'Self' END AS Self, | |
a.Score, | |
a.CreationDate, | |
CASE WHEN q.CommunityOwnedDate IS NOT NULL THEN 'Q' | |
WHEN a.CommunityOwnedDate IS NOT NULL THEN 'A' END AS CW | |
FROM | |
Posts q | |
INNER JOIN | |
Posts a ON q.Id = a.ParentId | |
WHERE | |
a.OwnerUserId = @UserId | |
AND | |
a.PostTypeId = 2 | |
AND | |
Year(q.CreationDate) = @Year | |
ORDER BY | |
a.Score DESC, a.CreationDate DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment