Determine Stack Overflow Activity Level

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT
  u.Id AS UserId,
  COUNT(DISTINCT q.Id) AS Questions,
  COUNT(DISTINCT a.Id) AS Answers,
  CAST(SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS BIGINT) AS Upvotes,
  CAST(SUM(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) AS BIGINT) AS Downvotes,
  CAST(SUM(q.ViewCount) AS BIGINT) AS QuestionsViewed,
  COUNT(DISTINCT f.PostId) AS Favourites,
  CAST(SUM(u.Views) AS BIGINT) AS ProfileViews
FROM
  Users u
LEFT JOIN
  Posts q ON u.Id = q.OwnerUserId AND q.PostTypeId = 1 AND q.CreationDate >= '2019-01-01' -- Limiting to posts from 2022 onwards
LEFT JOIN
  Posts a ON u.Id = a.OwnerUserId AND a.PostTypeId = 2 AND a.CreationDate >= '2019-01-01'
LEFT JOIN
  Votes v ON u.Id = v.UserId AND v.CreationDate >= '2019-01-01'
LEFT JOIN
  PostHistory f ON u.Id = f.UserId AND f.PostHistoryTypeId = 5 AND f.CreationDate >= '2019-01-01'
WHERE
  u.Id IN (1, 16030423, 22)
GROUP BY
  u.Id

Enter Parameters

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