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

0

Please login or register to vote for this query.

(click on this box to dismiss)

Science Fiction and Fantasy Meta

Q&A about the site for science fiction and fantasy enthusiasts

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

Select id from users
where id='-1'

Enter Parameters

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