SQL数据库编程

4、请根据机试笔试平均分和下面的评分规则,编写T-SQL语句查询学员的成 绩。
优 :90分以上
良 :80-89分
中 :70-79分
差 :60-69分
不及格 :60分以下(case)5、则根据如下规则对机试成绩进行反复加分,直到平均分超过85分为止。请编写T-SQL语句实现。
90分以上: 不加分
80-89分: 加1分
70-79分: 加2分
60-69分: 加3分
60分以下: 加5分

while 平均分<85
begin
update 表 set 平均分=平均分+ (case 变量 when 平均分<90 and 平均分>80 then 1
when 平均分<80 and 平均分>70 then 2
when 平均分<70 and 平均分>60 then 3
when 平均分<60 then 5)
end
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-07-06
4、 select case 评语 =
when 成绩>90 then '优'
when 成绩>80 then '良'
when 成绩>70 then '中'
when 成绩>60 then '差'
when 成绩<60 then '不及格'
end

第二个题目有点不清楚,不予作答
第2个回答  2013-07-06
count(*) from tabel where cj>=90count(*) from tabel where cj>=80 and cj<=89count(*) from tabel where cj>=70 and cj<=79count(*) from tabel where cj>=60 and cj<=69count(*) from tabel where cj<=60
相似回答