set nocount on declare @TagSet table (TagPostID int) dec...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping Meta

Q&A about the site for gardeners and landscapers

-- Enter Query Title
-- Enter Query Description

set nocount on
declare @TagSet table (TagPostID int)
declare @TagSearch int = ##TagId##

insert @TagSet
select PostID 'PostId' from PostTags where TagID = @TagSearch

set nocount off

select
 t.Id,
 t.TagName, 

 count(*) 
from PostTags pt join @TagSet ts on ts.TagPostID = pt.PostId
 join Tags t on pt.TagId = t.Id
 join Posts p on pt.PostId = p.Id 
where t.Id != @TagSearch

group by t.Id, t.TagName

Enter Parameters

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