RQb.Posts

0

Please login or register to vote for this query.

(click on this box to dismiss)

SharePoint

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;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results