上面这样一张表users,写sql语句查询出来要达到下面的效果

select name,

  (select grade from users m where subject='语文' and m.name=users.name)as 语文,

  (select grade from users m where subject='数学' and m.name=users.name)as 数学,

  (select grade from users m where subject='地理' and m.name=users.name)as 地理,

  (select grade from users m where subject='英语' and m.name=users.name)as 英语

from users

group by name;

posted on 2018-11-08 13:20  李留广  阅读(167)  评论(0编辑  收藏  举报