Question 2

0

Please login or register to vote for this query.

(click on this box to dismiss)

Korean Language

Q&A for linguists, teachers and students of the Korean language

SELECT TOP 10 
    Users.ID, 
    Users.DisplayName, 
    PostCounts.PostCount + CommentCounts.CommentCount AS PostsAndComments
FROM Users
LEFT JOIN (
    SELECT OwnerUserID, COUNT(*) AS PostCount
    FROM Posts
    WHERE CreationDate >= DATEADD(YEAR, -5, GETDATE())
    GROUP BY OwnerUserID
) AS PostCounts ON Users.ID = PostCounts.OwnerUserID
LEFT JOIN (
    SELECT UserID, COUNT(*) AS CommentCount
    FROM Comments
    WHERE CreationDate >= DATEADD(YEAR, -5, GETDATE())
    GROUP BY UserID
) AS CommentCounts ON Users.ID = CommentCounts.UserID
ORDER BY PostsAndComments DESC;

Enter Parameters

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