【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《case语句循环语句》,欢迎阅读!

Case语句:分支语句.(如 switch()) 格式:
Case 变量名
When <常量表达式> then <结果表达式> …..
Else <结果表达式> end
例:根据StudentClass数据库中的表class,完成如下操作: Java,jsp 在输出备注提示:软件日语专业课程 C语言在输出备注提示基础学科.
select 备注=case when 面积>300 then '大仓库' when 城市='上海' then '上海的仓库' end from 仓库
注:上海仓库没有显示出来
根据成绩判定级别:
select 课程号,备注= case
when 成绩>=90 and 成绩<100 then '优秀' when 成绩>=80 and 成绩<90 then '良好' when 成绩>=70 and 成绩<80 then '中等' when 成绩>=60 and 成绩<70 then '及格' else '不及格' end from score
Waitfor 格式
Waitfor delay ‘时间’ 时间:hh:mm:ss
循环:while 格式:
While 逻辑表达式 Begin [Break]; [continue] end
例子:求从1加到10的以内的和
declare @i int set @i=0
declare @s int set @s=0 while @i<=10 begin set @i=@i+1
if(@i%2=1) continue set @s=@s+@i end print @s
本文来源:https://www.wddqxz.cn/7527ee2475c66137ee06eff9aef8941ea76e4bae.html