Q&A for administrators, end users, developers and designers for Craft CMS
--- Comments --- fill a temporary #users19 ,users who have posted at least one Q or one A 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)) --- 409716 select u.UID, count (distinct c.Id) K from #u19 u inner join Comments c on u.UID = c.UserId where c.CreationDate >= u.UCD and u.UID > 11545826 group by (u.UID) order by u.UID