Show my vote history for a specific tag.
VoteTypeFilter is optional, but the UI forces you to at least throw a space in there. The filter is a case insensitive filter on the VoteType column so you can enter 'up', 'accepted' or 'bounty' for example to filter those. For a full list of vote types see http://data.stackexchange.com/stackoverflow/query/73707/list-of-all-votetypes.
Q&A about the site for serious players and enthusiasts of poker
declare @UserId int = ##UserId##;
declare @TagName varchar(25) = ##TagName:string##;
declare @VoteTypeFilter varchar(50) = ##VoteTypeFilter:string##;
-- Map tag data that exists on question posts onto answer post rows.
with PostQuestionMappings as (
IsNull(p.ParentId, p.Id) as QuestionId,
IsNull(p.Tags, q.Tags) as Tags,
from Posts p
left outer join Posts q on (q.id = p.ParentId)
where p.OwnerUserId = @UserId
select top 2000
convert(varchar(10), v.CreationDate, 111) as VoteDate,
v.PostId as [Post Link],
vt.Name as VoteType,
count(*) as Amount,
from PostQuestionMappings p
join PostTags pt on (p.QuestionId = pt.PostId)
join Tags t on (pt.TagId = t.Id)
join Votes v on (p.Id = v.PostId)
join VoteTypes vt on (v.VoteTypeId = vt.Id)
where t.TagName = @TagName
and (rtrim(@VoteTypeFilter) = ''
or lower(vt.Name) like '%' + lower(@VoteTypeFilter) + '%')
group by v.CreationDate, v.PostId, vt.Name, v.BountyAmount, p.Tags, p.CommunityOwnedDate, vt.Id
order by v.CreationDate desc, vt.Id