Ordinary ranks conversion of the SQL statement

Suppose Zhang Xuesheng results table (tb_rowtocol) follows
Name Subject Result
Joe Smith Language 73
Joe Smith Mathematics 83
Joe Smith Physics 93
John Doe Language 74
The John Doe Mathematics 84
The John Doe physical 94

Want to become
Name the language of mathematical physics
Joe Smith 738 393
John Doe 748 494

DECLARE @ sql varchar (4000)
set @ sql = ‘select Name as’ + ‘Name’
select @ sql = @ sql + ‘, sum (case Subject when”’ + Subject +” ‘then Result end) [‘ + Subject + ‘]’
from (select distinct Subject from rowtocol) as a
set @ sql = @ sql + ‘from rowtocol group by name’
the exec (_AT_ sql)

If the two tables interchangeably:
Table name (cj)
Name the language of mathematical physics
Joe Smith 738 393
John Doe 748 494

Want to become

Name Subject Result
Joe Smith Language 73
Joe Smith Mathematics 83
Joe Smith Physics 93
John Doe Language 74
The John Doe Mathematics 84
The John Doe physical 94

select name as name, ‘language’ as Subject, Language as result from CJ Union
select name as the name ‘math’ as ??Subject, mathematics as result from CJ Union
select name as name, ‘physical’ as Subject, physical as Result from CJ
order by name desc