MS sql server 2005 数据查询语句如何写?

2024-11-09 06:26:01
推荐回答(1个)
回答1:

写的有点复杂,但能实现你要的效果,而且效率很底,建议你用存储过程比较好。

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