WITH TempTable AS ( SELECT OwnerUserId FROM posts WHERE P...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Writing

Q&A for the craft of professional writing, including fiction, non-fiction, technical, scholarly, and commercial writing

WITH TempTable AS (
    SELECT 
        OwnerUserId
    FROM posts
    WHERE PostTypeId = 1
    GROUP BY OwnerUserId
    HAVING 
        COUNT(CASE WHEN CreationDate BETWEEN '2021-09-06' AND '2021-11-27' THEN Id ELSE NULL END) >= 1
        AND 
        COUNT(CASE WHEN CreationDate BETWEEN '2021-12-05' AND '2022-02-27' THEN Id ELSE NULL END) >= 1
),
UserTagFirstUsage AS (
    SELECT 
        p.OwnerUserId,
        pt.TagId,
        MIN(p.CreationDate) AS FirstTagUsageDate
    FROM posts p
    JOIN PostTags pt ON p.Id = pt.PostId
    JOIN TempTable t ON p.OwnerUserId = t.OwnerUserId
    WHERE p.PostTypeId = 1
    GROUP BY p.OwnerUserId, pt.TagId
),
NewTagsPerDate AS (
    SELECT 
        ROW_NUMBER() OVER (ORDER BY u.OwnerUserId DESC) AS IndexColumn,
        u.OwnerUserId,
        u.FirstTagUsageDate AS CreationDate,
        COUNT(u.TagId) AS NewTagsCount
    FROM UserTagFirstUsage u
    WHERE u.FirstTagUsageDate BETWEEN '2021-09-06' AND '2022-02-27'
    GROUP BY u.OwnerUserId, u.FirstTagUsageDate
)
SELECT 
    OwnerUserId,
    CreationDate,
    NewTagsCount
FROM NewTagsPerDate
ORDER BY IndexColumn desc;

Enter Parameters

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