sql语句 case

case:

SELECT stdname, 
max( CASE WHEN stdsubject = '语文' THEN  result ELSE 0 END) "语文", 
max( CASE WHEN stdsubject = '数学' THEN  result ELSE 0 END) "数学",
max( CASE WHEN stdsubject = '物理' THEN  result ELSE 0 END) "物理" ,
max( CASE WHEN stdsubject = '化学' THEN result ELSE 0 END)  "化学"
FROM  std 
GROUP BY stdname;

posted on 2013-11-07 23:02  小-强-斋-太  阅读(149)  评论(0编辑  收藏  举报

导航