Top 10 users who made the most posts and comments over the past 5 years

0

Please login or register to vote for this query.

(click on this box to dismiss)

Computational Science

Q&A for scientists using computers to solve scientific problems

SELECT TOP 10 u.id, COUNT(*) AS activity
FROM Users u
LEFT JOIN (
SELECT p.OwnerUserId AS user_id
FROM posts p
WHERE p.CreationDate >= DATEADD(YEAR, -5, GETDATE())
    
UNION ALL
    
SELECT c.UserId AS user_id
FROM Comments c
WHERE c.CreationDate >= DATEADD(YEAR, -5, GETDATE())
) AS user_activity ON u.id = user_activity.user_id
GROUP BY u.id
ORDER BY COUNT(*) DESC

Enter Parameters

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