How can I achieve the format I want? I don't want duplicate Name
Use the GROUP BY
clause to aggregate the duplicate names, as in this query:
SELECT U.Id as [User Link], Count(Pt.Id) AS ANSWERS
FROM Users U, Posts P, PostHistory Ph, PostTypes Pt
WHERE
Pt.Id = Ph.PostHistoryTypeId
AND
U.Id = P.OwnerUserId
AND
P.Id = Ph.PostId
AND
Pt.Id = 2
GROUP BY U.Id
HAVING Count(Pt.Id) > 2000
ORDER BY ANSWERS DESC
References