Declare @t1 table ( Name varchar(10), Class varchar(10), Math int, Physics int, English int)Insert Into @t1Select 'Alok', 'V', 60, 50, 45 Union AllSelect 'Bobby', 'V', 78, 87, 86 Union AllSelect 'Chandini', 'VI', 56, 76, 56 Union AllSelect 'Dolly', 'VII', 87, 56, 66Select Class, Physics = sum(case Class when 'V' then Physics else 0 end), Math = sum(case Class when 'VI' then Math else 0 end), English = sum(case Class when 'VII' then English else 0 end)From @t1Group By Class
CoreysnSQL on previous signature "...Oh and by the way Seventhnight, your signature is so wrong! On so many levels, morally, gramatically and there is a typo!"