Works perfectly for me:declare @a table(Name varchar(20),Score int,ExamName varchar(20))insert @aselect 'John',53,'English' union allselect 'John',98,'Mathematics' union allselect 'John',78,'Science' union allselect 'Peter',87,'English' union allselect 'Peter',70,'Mathematics' union allselect 'Peter',82,'Science' union allselect 'Jane',98,'English' union allselect 'Jane',91,'Mathematics' union allselect 'Jane',86,'Science'select * from @apivot(max(score) for ExamName in (English,Mathematics,Science)) as t
Harsh Athalyehttp://in.linkedin.com/in/harshathalye/