Q&A for meta-discussion of the Stack Exchange family of Q&A websites
create table #u19 (UID int, UCD datetime); go insert into #u19 select u.Id UID, u.CreationDate UCD from Users u where u.CreationDate >= '2019-01-01' and u.CreationDate < '2020-01-01' and exists (select * from Posts p2 where p2.OwnerUserId = u.Id and p2.Creationdate >= '2019-01-01' and p2.PostTypeId in (1,2)) --- 409753 create table #fpq5 (UID int, UCD datetime, FPID int, FPCD datetime, SPID int, SPCD datetime, DLY int); go insert into #fpq5 -- MA5_AB select u.UID UID, u.UCD UCD, p.Id FPID, p.CreationDate FPCD, p3.Id, p3.CreationDate, datediff (mi, p.CreationDate, p3.CreationDate) DLY from #u19 u inner join Posts p on u.UID = p.OwnerUserId inner join Posts p3 on u.UID = p3.OwnerUserId and p3.ParentId = p.Id where p.PostTypeId = 1 and p.CreationDate >= '2019-01-01' and p.CreationDate = (select min (p2.CreationDate) from Posts p2 where p2.OwnerUserId = u.UID and p2.CreationDate > u.UCD and p2.PostTypeId in (1,2)) and p3.PostTypeId = 2 and p3.CreationDate > p.CreationDate select count (*) from #fpq5 select f.UID UID, f.UCD UCD, f.FPID FPID, f.FPCD FPCD, p4.Id SPID, p4.CreationDate SPCD, datediff (mi, f.FPCD, p4.CreationDate) --select count (distinct f.UID) from #fpq5 f inner join Posts p4 on p4.OwnerUserId = f.UID where p4.PostTypeId in (1,2) --- second Post was Q OR A and p4.CreationDate > f.FPCD order by f.UID select count (distinct f.UID) from #fpq5 f where not exists (select * from Posts p5 where p5.OwnerUserId = f.UID and p5.PostTypeId in (1,2) --- second Post was Q OR A and p5.CreationDate > f.FPCD)