表Student:

张三  语文  80

张三  数学  79

张三  英语  96

李四  语文  85

李四  数学  60

李四  英语  94

  转换格式如下:

李四 85 60 94
张三 80 79 96

SQL语句:

select name 姓名,
max(case subject when '语文' then result else 0 end) 语文,
max(case subject when '数学' then result else 0 end) 数学,
max(case subject when '英语' then result else 0 end) 物理
from student
group by name

 

-----------------------

http://www.cnblogs.com/skywang/articles/1423085.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2022-01-13
  • 2022-12-23
  • 2022-01-09
猜你喜欢
  • 2022-12-23
  • 2021-06-19
  • 2022-02-15
相关资源
相似解决方案