日期:2014-05-18  浏览次数:20575 次

求sql语句 菜鸟问题
如何根据成绩表显示如下的查询结果:
                                        学号         平均分 等级
                                      2006001                     95 A
                                      2006002                 89 B
                    2006003                   77 C
                    2006004                 56 E
                    2006005                 60 D
平均分> =90为A   > =80为B   > =70为C   > =60为D   小于60为E

表里有     学号     各科成绩     还有科目       问下怎么用select...case语句   写这种显示

------解决方案--------------------
select 学号,平均分,科目
等级= case when s> =90 then 'A '
when s> =80 and s <90 then 'B '
when s <80 and s> =70 then 'C '
when s <70 and s> =60 then 'D '
when s <60 then 'E '
else '无等级 '
end
from temptab