Synonym level


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

with synonyms (target, source, level)
as (
  select targettagname, sourcetagname, 1
  from tagsynonyms
  where approvaldate is not null
  and not targettagname in (select sourcetagname from tagsynonyms)
  union all
  select target, sourcetagname, level+1
  from tagsynonyms
  inner join synonyms on source=targettagname
  where approvaldate is not null
select coalesce(level, 0) level,
  coalesce(count(*), 0) count,
  coalesce(sum(case when coalesce(count, 0)!=0 then 1 end), 0) nonempty
from tags
full join synonyms on tagname=source
group by level
order by level

Enter Parameters

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