Q&A for professional and enthusiast programmers
select --top 100 *, datediff(day, p.CreationDate, u.LastAccessDate) --min(p.CreationDate), max(p.CreationDate), max(u.LastAccessDate), case when datediff(day, u.CreationDate, u.LastAccessDate) > ##cutoff?30## and datediff(day, u.CreationDate, p.CreationDate) > ##cutoff## then 'Regular' else 'Drive by' end user_type, --round(avg(Score*1.0), 2) avg_score, count(*) answers from Posts p join Users u on u.Id = OwnerUserId where p.PostTypeId = 2 and datediff(day, p.CreationDate, getdate()) between ##cutoff## and 365 + ##cutoff## and Score > 0 group by case when datediff(day, u.CreationDate, u.LastAccessDate) > ##cutoff## and datediff(day, u.CreationDate, p.CreationDate) > ##cutoff## then 'Regular' else 'Drive by' end order by count(*) desc