create table #u19 (UID int, UCD datetime); go insert int...


Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

create table #u19 (UID int, UCD datetime);

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'
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);

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 and p.AcceptedAnswerId = p3.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

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results