Q&A about the site for expert genealogists and people interested in genealogy or family history
SELECT TOP 10 Users.Id, COUNT(DISTINCT Badges.Id) AS Badge_Amount, MAX(Posts.CreationDate) AS Last_Post, Users.Location FROM Users LEFT JOIN Badges ON Badges.UserId = Users.Id LEFT JOIN Posts ON Posts.OwnerUserId = Users.Id WHERE Users.Location LIKE '%Latvia%' GROUP BY Users.Id, Users.Location HAVING COUNT(Badges.Id) > 100 AND MAX(Posts.CreationDate) > '2021-01-01' ORDER BY Badge_Amount DESC;