Q&A about the site for enthusiasts and scholars of mythology and folklore
-- 3. Enhance the query created in point 2 -- in a way that the list of top users contains -- only those users who have at least one post in 2021. SELECT Users.Id, Users.DisplayName, COUNT(Badges.Id) AS NumberOfBadges FROM Users INNER JOIN Badges ON Badges.UserId = Users.Id WHERE Users.Location LIKE '%Latvia%' AND EXISTS ( SELECT 1 FROM Posts WHERE Posts.OwnerUserId = Users.Id AND Posts.CreationDate >= '2021-01-01' AND Posts.CreationDate < '2022-01-01' ) GROUP BY Users.Id, Users.DisplayName HAVING COUNT(Badges.Id) > 100 ORDER BY NumberOfBadges DESC