Q&A about the site for practitioners, researchers, and students in cognitive science, psychology, neuroscience, and psychiatry
declare @EndDate datetime = (select case -- If we request 'today', actually use the date -- of the most recent transfer to this database, -- which may be as much as a week in the past. when lower(##EndDate:string?today##) = 'today' then max(CreationDate) -- Otherwise, specify the most recent date to include. else ##EndDate## end from Posts ); declare @StartDate datetime = dateadd(day, -1*##DaysBack?30##, @EndDate); SELECT Posts.OwnerUserId [User Link], ParentId [Post Link] FROM Posts WHERE Posts.CreationDate between @StartDate and @EndDate GROUP BY Posts.ParentId, Posts.OwnerUserId HAVING COUNT(Posts.ParentId) > 1