You don't need a cursor for this:SELECT (T.Radio_Type + ', ' + T.Installation + ', ' + T.Movement) AS RunName,SUM(CASE WHEN V.Score=0 THEN 1 END) Zero,SUM(CASE WHEN V.Score=1 THEN 1 END) One,SUM(CASE WHEN V.Score=2 THEN 1 END) Two,SUM(CASE WHEN V.Score=3 THEN 1 END) Three,SUM(CASE WHEN V.Score=4 THEN 1 END) Four,SUM(CASE WHEN V.Score=5 THEN 1 END) Five,COUNT(*) Total,SUM(CASE WHEN V.Score BETWEEN 0 AND 5 THEN 1 END) [Sum]INTO MyNewTableFROM Test_Info TINNER JOIN Raw_Voice V ON T.Run_no=V.Run_noWHERE V.T_R='r'GROUP BY (T.Radio_Type + ', ' + T.Installation + ', ' + T.Movement), T.Run_no
That will put the results into MyNewTable.