Q&A for people looking to bypass life's everyday problems with simple tricks
-- Currently this does "What are the top answers for a tag?" instead -- of "Who?" -- Without GROUP BY, I'm seeing duplicate a.Id when they use multiple of my -- included tag names.. http://stackoverflow.com/q/5391564/149428 --DECLARE @UserId int = ##UserId## DECLARE @UserId int = 149428 DECLARE @TagList varchar = 'css,html' PRINT @TagList PRINT 'css,html' SELECT TOP 25 a.Id, a.ParentId, a.Score, a.OwnerUserId, q.Title, q.Tags, q.AnswerCount, q.FavoriteCount --SELECT TOP 25 a.Id, a.Score, a.ParentId, a.OwnerUserId FROM Posts AS a INNER JOIN Posts AS q ON q.Id = a.ParentId INNER JOIN PostTags ON q.Id = PostTags.PostId INNER JOIN Users ON a.OwnerUserId = Users.Id WHERE PostTags.TagId IN ( SELECT Id FROM Tags --WHERE TagName IN ('python', 'python-2.7', 'python-3.x') WHERE TagName IN ( SELECT * --FROM string_split('python,python-2.7,python-3.x', ',') FROM string_split('css,html', ',') ) ) AND a.Score >= 1 AND a.OwnerUserId = @UserId --GROUP BY a.Id, a.ParentId, a.Score, a.OwnerUserId --GROUP BY a.OwnerUserId ORDER BY a.Score DESC