Öyle "görünen" bir sorgu
SELECT T2.Tag, COUNT(*)
FROM SO_Posts P1
JOIN Post_Tags T1 ON P.PostId = T1.PostId
JOIN Post_Tags T2 ON P.PostId = T2.PostId
GROUP BY T2.Tag
WHERE T1.Tag = 'PHP'
ORDER BY COUNT(*) DESC
This query makes the plausible assumption that the Posts (Questions) on SO are stored in two tables;
*SO_Posts*, containing one record per Post, and holding info such as a PostId (Primary Key), the question itself, the date, the title etc.
and
*Post_Tags* which associates a given Post (by its Post_Id) with a Tag (or more likely a TagId since tags ought to be normalized, but that's a detail). For a given Post, there are as many records in *Post_Tags* as there are different tags attached to the post.
Note: in effect the structure of the SO Posts database is more complicated, with various tables for storing comments, replies etc. but with regards to the Post-to-Tag relationship, this two-table layout (or more likely a 3 tables layout allowing to have a tagId in the *Post_Tags* rather than the tag itself) captures the essence of how it is possible, easy and fast (provided the right indexes) to show these filtered agregate counts.
Fikir (burada 'PHP') hedeflenen etiketinin ("T1" baktım-up) ile ilgili tüm PostIDs bulmak ve sonra Tag, ("T2" olarak) tüm Mesajını toplamaktır.Daha.
Ana tablo SO_Posts burada gerekli değildir, ama büyük olasılıkla böyle Mesaj durumu (kapalı olması değil ...) demek gibi ekstra kriterleri ekleyerek izin örneğin, sorgunun bir parçası olacağını unutmayın.