It works for me:declare @t table (number int, duration int)insert @tselect 1234,3 union allselect 1234,4 union allselect 1234,3 union allselect 1234,4 union allselect 1234,3 union allselect 1234,4 union allselect 1234,3 union allselect 1234,10 union allselect 1234,11 union allselect 1234,4 union allselect 1234,3 union allselect 1234,4 union allselect 1234,12 union allselect 1234,14 union allselect 1234,13 union allselect 1234,24 union allselect 1234,3 union allselect 1234,24select [number] ,convert(varchar(3), 10*([duration]/10)) + ' - ' + convert(varchar(3), 10*([duration]/10)+9) ,count(number) [count]from @t --statsgroup by [number] ,[duration]/10order by [number] ,[duration]/10OUTPUT:number count----------- --------- -----------1234 0 - 9 111234 10 - 19 51234 20 - 29 2
Be One with the OptimizerTG