Tag Totals, grouped by Target Tag Synonyms

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

SELECT TagTotals.TagName, Sum(TagTotals.Count) FROM(

SELECT TagSynonyms.TargetTagName as TagName,
  Tags.Count
FROM
  Tags INNER JOIN TagSynonyms ON (
    Tags.TagName = TagSynonyms.SourceTagName
  )
UNION

SELECT Tags.TagName,
  Tags.Count
  
FROM
  Tags LEFT JOIN TagSynonyms ON (
    Tags.TagName = TagSynonyms.SourceTagName
  )
WHERE
  TagSynonyms.SourceTagName IS NULL
  
  ) as TagTotals
GROUP BY TagTotals.TagName ORDER BY 2 DESC, 1;

Enter Parameters

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