Q&A for people studying math at any level and professionals in related fields
create table #spammers(accountid int, site sysname, creationdate datetime) exec sede_ineachdb ' insert into #spammers select accountid, [$site name$] site, creationdate from users where reputation = 1 and displayname like ''%spam%'' COLLATE Latin1_General_100_CI_AI ', 1 , 0 , 0, 0 select accountid [# spam profiles] , count(*) [# of sites] , min(creationdate) [min data] , max(creationdate) [max data] from #spammers where accountid is not null group by accountid order by count(*) desc, datediff(d, max(creationdate), min(creationdate)) desc