tag with count, excerpt content, wiki content, and synonyms names

0

Please login or register to vote for this query.

(click on this box to dismiss)

Bicycles

Q&A for people who build and repair bicycles, people who train cycling, or commute on bicycles

SELECT
    DISTINCT t.TagName,
    COALESCE(ts.AlternativeName, t.TagName) as AlternativeName,
    t.Count as TagCount,
    t.ExcerptPostId as TagExcerptPostId,
    p1.Body AS ExcerptBody,
    t.WikiPostId as TagWikiPostId,
    p2.Body AS WikiBody
FROM
    Tags as t
    LEFT JOIN (
        SELECT
            TargetTagName AS [Tag],
            TargetTagName AS [AlternativeName]
        FROM
            TagSynonyms
        WHERE
            ApprovalDate IS NOT NULL
        union
        all
        SELECT
            TargetTagName AS [Tag],
            SourceTagName AS [AlternativeName]
        FROM
            TagSynonyms
        WHERE
            ApprovalDate IS NOT NULL
    ) as ts ON t.TagName = ts.Tag
    LEFT JOIN Posts AS p1 ON t.ExcerptPostId = p1.Id
    LEFT JOIN Posts AS p2 ON t.WikiPostId = p2.Id
WHERE t.Count > 11
ORDER BY
    t.Count DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results