In case of SQL Server 2017 or vnext we can use in-built STRING_AGG for this aggregation. For same student table,
create table #yourstudent (subjectid int, studentname varchar(10))
insert into #yourstudent (subjectid, studentname) values
( 1 ,'Mary' )
,( 1 ,'John' )
,( 1 ...