试试这个 :
select english , chemistry , physics from (
select (select percentage from Table1 where subject = 'English' ) as english,
(select percentage from Table1 where subject = 'Chemistry') as chemistry,
(select percentage from Table1 where subject = 'Physics') as physics
from Table1 group by english
union all
select (select Grade from Table1 where subject = 'English' ) as english,
(select Grade from Table1 where subject = 'Chemistry') as chemistry,
(select Grade from Table1 where subject = 'Physics') as physics
from Table1 group by english
) t
输出:
ENGLISH CHEMISTRY PHYSICS
40% 80% 50%
D A C
在这里演示