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)

Code Golf and Coding Challenges Meta

Q&A about the site for programming puzzle enthusiasts and code golfers

WITH TempTable AS (
    SELECT 
        OwnerUserId,
        COUNT(CASE WHEN CreationDate BETWEEN '2020-09-06' AND '2020-11-29' THEN Id ELSE NULL END) AS CountPeriodA,
        COUNT(CASE WHEN CreationDate BETWEEN '2020-12-06' AND '2021-02-28' THEN Id ELSE NULL END) AS CountPeriodB
    FROM posts
    WHERE PostTypeId = 1
    GROUP BY OwnerUserId
    HAVING 
        COUNT(CASE WHEN CreationDate BETWEEN '2020-09-06' AND '2020-11-29' THEN Id ELSE NULL END) >= 1
        AND 
        COUNT(CASE WHEN CreationDate BETWEEN '2020-12-06' AND '2021-02-28' THEN Id ELSE NULL END) >= 1
),
FINAL As(
SELECT 
    ROW_NUMBER() OVER (ORDER BY posts.OwnerUserId DESC) AS IndexColumn,
    posts.OwnerUserId,
    posts.Id,
    posts.CreationDate,
    posts.body
FROM posts 
INNER JOIN TempTable ON posts.OwnerUserId = TempTable.OwnerUserId
WHERE PostTypeId=1 AND CreationDate between '2020-09-06' and '2021-02-28'
GROUP BY posts.OwnerUserId,posts.Id, posts.CreationDate,posts.body,posts.tags
)
Select *
From FINAL
where Indexcolumn >= 49999 and Indexcolumn < 99999
order by Indexcolumn

Enter Parameters

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