Q&A about the site for expert genealogists and people interested in genealogy or family history
WITH RankedPosts AS ( SELECT Users.Id AS UserId, Users.Location, Badges.Name AS BadgeName, Posts.Id AS PostId, Posts.CreationDate, ROW_NUMBER() OVER (PARTITION BY Users.Id ORDER BY Posts.CreationDate DESC) AS RowNum FROM Users, Badges, Posts, PostTypes WHERE Users.Id = Badges.UserId AND Users.Id = Posts.OwnerUserId AND Posts.PostTypeId = PostTypes.Id AND Users.Location LIKE '%Latvia%' AND Badges.Name = 'Editor' AND PostTypes.Name = 'Question' ) SELECT UserId, Location, BadgeName, PostId, CreationDate FROM RankedPosts WHERE RowNum = 1 ORDER BY UserId ASC;