Q&A about the site for professional linguists and others with an interest in linguistic research and theory
-- postId is the top question postId declare @postId1 as int,@postId2 as int,@postId3 as int,@postId4 as int,@postId5 as int declare @postId6 as int,@postId7 as int,@postId8 as int,@postId9 as int,@postId10 as int set @postId1 = 2512683; set @postId2 = 2512691; set @postId3 = 2512696; set @postId4 = 2512698; set @postId5 = 2512702; set @postId6 = 2512713; set @postId7 = 2512717; set @postId8 = 2512718; set @postId9 = 2512720; set @postId10 = 2512723; -- remember that union will remove duplicate already -- Get all users who COMMENTED on a question post and all of its responses select x.Id,x.Reputation,x.CreationDate,x.DisplayName,x.LastAccessDate,x.WebsiteUrl,x.Location,x.AboutMe,x.Views,x.UpVotes,x.DownVotes,x.ProfileImageUrl,x.EmailHash,x.AccountId from Users x inner join (select UserId from Comments c inner join (select * from Posts where Id = @postId1 or Id = @postId2 or Id = @postId3 or Id = @postId4 or Id = @postId5 or Id = @postId6 or Id = @postId7 or Id = @postId8 or Id = @postId9 or Id = @postId10 UNION select * from Posts where ParentId = @postId1 or ParentId = @postId2 or ParentId = @postId3 or ParentId = @postId4 or ParentId = @postId5 or ParentId = @postId6 or ParentId = @postId7 or ParentId = @postId8 or ParentId = @postId9 or ParentId = @postId10 ) d on c.PostId = d.Id) y on x.Id = y.UserId UNION -- Get all users who writes a response post (also including the post author) to a a set of questions select y.Id,y.Reputation,y.CreationDate,y.DisplayName,y.LastAccessDate,y.WebsiteUrl,y.Location,y.AboutMe,y.Views,y.UpVotes,y.DownVotes,y.ProfileImageUrl,y.EmailHash,y.AccountId from ( select OwnerUserId as personID from Posts where Id = @postId1 or Id = @postId2 or Id = @postId3 or Id = @postId4 or Id = @postId5 or Id = @postId6 or Id = @postId7 or Id = @postId8 or Id = @postId9 or Id = @postId10 union select OwnerUserId as personID from Posts where ParentId = @postId1 or ParentId = @postId2 or ParentId = @postId3 or ParentId = @postId4 or ParentId = @postId5 or ParentId = @postId6 or ParentId = @postId7 or ParentId = @postId8 or ParentId = @postId9 or ParentId = @postId10 union select LastEditorUserId as personID from Posts where ParentId = @postId1 or ParentId = @postId2 or ParentId = @postId3 or ParentId = @postId4 or ParentId = @postId5 or ParentId = @postId6 or ParentId = @postId7 or ParentId = @postId8 or ParentId = @postId9 or ParentId = @postId10 union select LastEditorUserId as personID from Posts where Id = @postId1 or Id = @postId2 or Id = @postId3 or Id = @postId4 or Id = @postId5 or Id = @postId6 or Id = @postId7 or Id = @postId8 or Id = @postId9 or Id = @postId10 ) x inner join Users y on x.personID = y.id