Q&A for SharePoint enthusiasts
WITH RankedPosts AS ( SELECT OwnerUserId, CreationDate, ROW_NUMBER() OVER (PARTITION BY OwnerUserId ORDER BY CreationDate) AS RowNum FROM Posts WHERE OwnerUserId IN ( SELECT Id FROM Users WHERE CreationDate BETWEEN '2008-01-01' AND '2024-10-01' ) ) SELECT OwnerUserId, MIN(CASE WHEN RowNum = 1 THEN CreationDate END) AS FirstPostDate, MIN(CASE WHEN RowNum = 2 THEN CreationDate END) AS SecondPostDate FROM RankedPosts GROUP BY OwnerUserId ORDER BY OwnerUserId;