I'm trying to find the user with the most upvotes from SE's data explorer: https://data.stackexchange.com/stackoverflow/query/105658
SELECT
Users.DisplayName as TheUser,
COUNT(Votes.Id) as TheUpvotes
FROM
Votes,
Users
WHERE
Votes.VoteTypeId=2
AND
Votes.UserId=Users.Id
GROUP BY
Users.DisplayName
This query returns 0 results. I can't figure out why. Can you?
Actually you don't need to join some tables. All that you need are found on table User
.
UPVOTES
as well as DOWNVOTES
are anonymous that is why you cannot count it. The value already exist on column UpVotes
and DownVotes
Query
SELECT [User Link], UpVotes, rn
FROM
(
SELECT a.ID as [User Link],
a.UpVotes,
DENSE_RANK() OVER (ORDER BY a.UpVotes DESC) rn
FROM Users a
)x
WHERE rn <= 10
ORDER BY UpVotes DESC