Q&A about the site for finance professionals and academics
SELECT p.Id AS [Post Link], p.CreationDate, SUM(Case When v.VoteTypeId = 2 Then 1 Else NULL End) AS UpVotes, SUM(Case When v.VoteTypeId = 3 Then 1 Else NULL End) AS DownVotes, ---2 = UpMod ---3 = DownMod p.Score, p.ViewCount, CASE WHEN p.PostTypeid=1 THEN 'Question' WHEN p.PostTypeId=2 THEN 'Answer' END, p.Tags FROM Posts p LEFT OUTER JOIN Votes v ON v.PostId=p.Id WHERE (p.OwnerDisplayName='user' + Convert(nvarchar(20), ##UserId##)) AND (p.PostTypeId IN (##types?1,2##)) ---1=answers ---2=questions ---1,2 both GROUP By p.Id, p.CreationDate, p.Score, p.ViewCount, p.PostTypeid, p.Tags ORDER BY p.CreationDate