Q&A for students and teachers of all martial arts
select [tag row], [python], [pandas], [sql] from ( select ptr.postid, trow.tagname [tag row], tcol.tagname [tag col] from posttags ptr inner join tags trow on trow.id = ptr.tagid inner join posttags ptc on ptr.postid = ptc.postid inner join tags tcol on tcol.id = ptc.tagid ) data pivot ( count(postid) for [tag col] in ([python], [pandas], [sql]) ) pvt order by 4 desc select tcol.tagname [tag col] , count(*) [# posts shared] from posttags ptr inner join tags trow on trow.id = ptr.tagid inner join posttags ptc on ptr.postid = ptc.postid inner join tags tcol on tcol.id = ptc.tagid where trow.tagname = 'python' group by tcol.tagname order by count(*) desc