Related Tags of Multiple By Time Range

1

Please login or register to vote for this query.

(click on this box to dismiss)

Gets the most commonly associated tags to a particular tag, by number of posts.

The Great Outdoors

Q&A for people who love being outdoors enjoying nature and wilderness, and learning about the required skills and equipment

SELECT 
  Tags.TagName AS [Tag Name], 
  COUNT(*) AS [Number of associated posts]
FROM PostTags
  INNER JOIN Tags
    ON Tags.Id = PostTags.TagId
  INNER JOIN Posts
    ON Posts.Id = PostTags.PostId
WHERE 
  PostTags.PostId IN 
  (
    --Gets all the PostIds that have this tag
    SELECT DISTINCT PostId
    FROM PostTags
      INNER JOIN Tags
        ON Tags.Id = PostTags.TagId
    WHERE 
       Tags.TagName = ##TagName1:string##
    OR Tags.TagName = ##TagName2:string##
    OR Tags.TagName = ##TagName3:string##
    OR Tags.TagName = ##TagName4:string##
    OR Tags.TagName = ##TagName5:string##
  )
  AND Posts.CreationDate >= ##PostFrom:string?2020-01-01##
GROUP BY Tags.TagName
ORDER BY COUNT(*) DESC

Enter Parameters

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