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)

Economics

Q&A for those who study, teach, research and apply economics and econometrics

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
),
TempAcceptID As(
SELECT 
    TempTable.OwnerUserId,
    posts.Id,
    posts.AcceptedAnswerId
FROM posts 
INNER JOIN TempTable ON posts.OwnerUserId = TempTable.OwnerUserId
WHERE PostTypeId=1 AND posts.CreationDate BETWEEN '2020-09-06' AND '2021-02-28'
GROUP BY TempTable.OwnerUserId,posts.Id, posts.AcceptedAnswerId
),
Acceptappear AS
(SELECT
    ROW_NUMBER() OVER (ORDER BY TempAcceptID.AcceptedAnswerId DESC) AS IndexColumn,
    TempAcceptID.Id,
    TempAcceptID.AcceptedAnswerId,
    Votes.CreationDate
FROM TempAcceptID
INNER JOIN Votes ON TempAcceptID.AcceptedAnswerId=Votes.postid
WHERE votetypeid=1
)
Select * 
From Acceptappear
where IndexColumn > 100000
Order by IndexColumn

Enter Parameters

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