http://www.cnblogs.com/NewLand/archive/2007/09/03/880540.html



 Create   table   test   ( [name] char(10), km char(10)   , cj int )
 
Go
 
--初始化数据
 insert   into   test   values('张三','语文',80)
 
insert   into   test   values('张三','数学',86)
 
insert   into   test   values('张三','英语',75)
 
insert   into   test   values('李四','语文',78)
 
insert   into   test   values('李四','数学',85)
 
insert   into   test   values('李四','英语',78)
 
Go

select name,sum(case km when '语文' then cj  endas 语文,
 
sum(case km when '数学' then cj  endas 数学,
 
sum(case km when '英语' then cj  endas 英语
 
from test
 
group by name

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2022-02-03
  • 2022-01-06
猜你喜欢
  • 2021-05-27
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-12-13
  • 2021-05-23
相关资源
相似解决方案