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:
相关问答:
如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP
参考:http://hi.baidu.com/toiota ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......
查询学生平均成绩及其名次
SELECT 1+(SELECT COUNT( distinct 平均成绩)
from (SELECT S#,AVG(score) AS 平均成绩
from SC&n ......