Which users have the highest badgesCount/rep ratio?
We have to be careful to exclude users with 1 rep, since those users almost certainly have been banned.
We end up with a query like this:
SELECT TOP 10 UserId AS [User Link],
(SELECT Reputation FROM Users WHERE Id=UserId) AS Reputation,
COUNT(*) AS [Total Badges],
cast(Count(*) as float)/(SELECT Reputation FROM Users WHERE Id=UserId) As Ratio
FROM Badges
WHERE (SELECT Reputation FROM Users WHERE Id=UserId) >= ##MinScore:int##
GROUP BY UserId
ORDER BY Ratio DESC
When the minimum rep threshold is 2, the top two users are:
User Link | Reputation | Total Badges | Ratio
user2497684 | 2 | 15 | 7.5
Narendra Sharma | 2 | 13 | 6.5
Raising the threshold to 200, we get these two users:
User Link | Reputation | Total Badges | Ratio
ant2009 | 636 | 886 | 1.3930817610062893
Peter Penzov | 603 | 560 | 0.9286898839137645
Which users have the highest badgesCount/rep ratio that have never spent rep on bounties?
Excluding users that have spent rep on a bounty, we get this query:
SELECT TOP 10 UserId AS [User Link],
(SELECT Reputation FROM Users WHERE Id=UserId) AS Reputation,
COUNT(*) AS [Total Badges],
cast(Count(*) as float)/(SELECT Reputation FROM Users WHERE Id=UserId) As Ratio
FROM Badges
WHERE ((SELECT Reputation FROM Users WHERE Id=UserId) >= ##MinScore:int##)
AND
((SELECT SUM(BountyAmount) FROM Votes WHERE Votes.UserId = Badges.UserId) is null)
GROUP BY UserId
ORDER BY Ratio DESC
When the minimum rep threshold is 2, we get the same top two users. With a threshold of 200, the top two users are:
User Link | Reputation | Total Badges | Ratio
Sonny Ordell | 209 | 79 | 0.37799043062200954
Tadit Dash | 315 | 111 | 0.3523809523809524