SELECT u.Id AS [User Link], u.Reputation AS Reputation, u...

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 [User Link],
  u.Reputation AS Reputation,
  u.Upvotes AS Upvoted,
  u.Downvotes AS Downvoted,
  (
    SELECT count(p.Id) FROM Posts p WHERE u.Id = p.OwnerUserId AND PostTypeId = 1
  ) AS Asked,
  (
    SELECT count(p.Id) FROM Posts p WHERE u.Id = p.OwnerUserId AND PostTypeId = 2
  ) AS Answered,
  (
    SELECT count(b.Id) FROM Badges b WHERE u.Id = b.UserId AND b.Class = 1
  ) AS [GoldenBadge],
  (
    SELECT count(b.Id) FROM Badges b WHERE u.Id = b.UserId AND b.Class = 2
  ) AS [SilverBadge],
  (
    SELECT count(b.Id) FROM Badges b WHERE u.Id = b.UserId AND b.Class = 3
  ) AS [BronzeBadges]
FROM Users AS u
WHERE u.Reputation > 0
ORDER BY u.Reputation DESC

Enter Parameters

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