易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL语句 - MS-SQL Server / 基础类

将学生选课成绩从百分制改为等级制(即A、B、C、D、E五级)。
使用存储过程
SQL code:
select case
when score >=0 and score<20 then 'E'
when score >=20 and score<40 then 'D'
when score >=40 and score<60 then 'C'
when score >=60 and score<80 then 'B'
else 'A'


select case
when (score-20)/20=0 then 'e'
when (score-20)/20=1 then 'd'
when (score-20)/20=2 then 'c'
when (score-20)/20=3 then 'b'
when (score-20)/20=4 then 'a' end

from tb

SQL code:
select
case
when score score>80 then 'A'
when score score<60 then 'B'
when score score<40 then 'C'
when score score<20 then 'D'
else 'E'
end
from tb


SQL code:
select
case
when score score>=80 then 'A'
when score score>=60 then 'B'
when score score>=40 then 'C'
when score score>=20 then 'D'
else 'E'
end
from tb
楼上手误,修正

SQL code:


相关问答:

sql小小的疑问 - .NET技术 / C#

可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

SQL语句问题 - MS-SQL Server / 疑难问题

请教高手:
 以下是数据库中的三条记录,英文为字段名称  
  id planname TaskBeginTime Status
329 2010年03 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号