写的有点复杂,但能实现你要的效果,而且效率很底,建议你用存储过程比较好。
select
(select
fenshu
from
table_1
where
(name=a.name)
and
(kemu='yuwen'))
yuwen,
(select
fenshu
from
table_1
where
(name=a.name)
and
(kemu='shuxue'))
shuxue,
(select
fenshu
from
table_1
where
(name=a.name)
and
(kemu='lishi'))
lishi
from
table_1
a
where
(a.name
in
(select
name
from
table_1))
group
by
a.name