An example of how to make an aggregated report, grouping together by values: select count(*) as total , count(case WHEN others = 1 THEN 1 END) as [one url], count(case WHEN others = 2 THEN 1 END) as [two urls], count(case WHEN others = 3 THEN 1 END) as [three urls], count(case WHEN others > 3 THEN 1 END) as [all the rest] from #temp2 ......