WITH TempTable AS ( SELECT OwnerUserId, COUNT(CASE WHEN C...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping

Q&A for gardeners and landscapers

WITH TempTable AS (
    SELECT 
        OwnerUserId,
        COUNT(CASE WHEN CreationDate BETWEEN '2022-09-04' AND '2022-11-27' THEN Id ELSE NULL END) AS CountPeriodA,
        COUNT(CASE WHEN CreationDate BETWEEN '2022-12-04' AND '2023-02-26' THEN Id ELSE NULL END) AS CountPeriodB
    FROM posts
    WHERE PostTypeId = 1
    GROUP BY OwnerUserId
    HAVING 
        COUNT(CASE WHEN CreationDate BETWEEN '2022-09-04' AND '2022-11-27' THEN Id ELSE NULL END) >= 1
        AND 
        COUNT(CASE WHEN CreationDate BETWEEN '2022-12-04' AND '2023-02-26' THEN Id ELSE NULL END) >= 1
),
FINAL AS (
    SELECT
        Comments.Id,
        Comments.PostId,
        Comments.CreationDate,
        Comments.Score
    FROM Comments
    INNER JOIN TempTable ON TempTable.OwnerUserId = Comments.Id
    WHERE Comments.CreationDate BETWEEN '2022-09-04' AND '2023-02-26'
)
SELECT * FROM FINAL

Enter Parameters

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