Number of users interested in either of the two tags and in both of them

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @VbaUsers1 as table (Id int primary key)
declare @VbaUsers2 as table (Id int primary key)

insert into @VbaUsers1
select Users.Id
from (
select count(*) as Nq, OwnerUserId from
Posts
join PostTags on Posts.Id = PostTags.PostId
join Tags on PostTags.TagId = Tags.Id
where Tags.TagName = 'excel-vba'
group by OwnerUserId
) as Vba
join Users on Vba.OwnerUserId = Users.Id
where Vba.Nq >= 5

insert into @VbaUsers2
select Users.Id
from (
select count(*) as Nq, OwnerUserId from
Posts
join PostTags on Posts.Id = PostTags.PostId
join Tags on PostTags.TagId = Tags.Id
where Tags.TagName = 'access-vba'
group by OwnerUserId
) as Vba
join Users on Vba.OwnerUserId = Users.Id
where Vba.Nq >= 5

select count(*) from @VbaUsers1
select count(*) from @VbaUsers2
select count(*)
from
(select w.Id as Id from @VbaUsers1 e
join @VbaUsers2 w on e.Id = w.Id) as b

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results