Select Common Tags Among Users with the Most Posts this week

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

SELECT ('site://tags/' + TagName + '|' + TagName) AS TagName
FROM Tags T
WHERE
T.Id IN (
        SELECT Pt.TagId FROM PostTags Pt
        WHERE Pt.PostId IN (
                           SELECT Ph.PostId FROM PostHistory Ph, PostHistoryTypes Pht
                           WHERE Pht.Id = Ph.PostHistoryTypeId
                           AND Ph.PostId IN(
                                           SELECT P.ParentId FROM Posts P
                                           WHERE P.ParentId = Ph.PostId
                                           AND P.PostTypeId = 2
                                           AND P.OwnerUserId = Ph.UserId
                                           AND DateDiff(week, P.CreationDate, GETDATE() ) < 1
                                           )
                                          GROUP BY Ph.PostId, Ph.UserId
                                          /*HAVING (SELECT Count(U.Id) FROM Users U WHERE U.Id = P.OwnerUserId) > 0*/ 
                           )
        )
ORDER BY T.TagName

Enter Parameters

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