WITH a AS ( SELECT IIF(DATEDIFF(DD, LAG(CreationDate) OVE...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Home Improvement Meta

Q&A about the site for contractors and serious DIYers

WITH a AS (
    SELECT
        IIF(DATEDIFF(DD, LAG(CreationDate) OVER (ORDER BY CreationDate), CreationDate) > 20, 1, 0) AS [GroupNo],
        *
    FROM
        Posts p
    WHERE
        PostTypeId = 6
    )
SELECT
    SUM(GroupNo) OVER (ORDER BY CreationDate),
    *
FROM
    a
ORDER BY CreationDate;

Enter Parameters

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