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


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

 count(*) as numPosts,
 sum(score) postScore,
 (sum(score)/count(*)) weight 
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
order by 3 desc 

Enter Parameters

Switch to main site
loading Hold tight while we fetch your results