Works for me:
create table #trial ( names varchar(10) ,
subject varchar(10) ,
marks varchar(10)
)
insert into #trial values ('ama' , 'maths' ,'A20')
insert into #trial values ('kay' , 'maths' ,'A30')
insert into #trial values ('kay' , 'geog' ,'A40')
insert into #trial values ('joh' , 'maths' ,'A50')
insert into #trial values ('joh' , 'geog' ,'A60')
insert into #trial values ('joh' , 'physics' ,'A70')
insert into #trial values ('ros' , 'english' ,'A80')
select * from #trial
drop table #trial
Gives
names subject marks
ama maths A20
kay maths A30
kay geog A40
joh maths A50
joh geog A60
joh physics A70
ros english A80