早教吧 育儿知识 作业答案 考试题库 百科 知识分享
早教吧考试题库频道 --> 计算机类考试 -->计算机三级 -->

设在SQL Server 2008某数据库中有表SC(Sn0,Cn0,Grade),其中Grade列的类型为int。若在查询成绩时,

题目

设在SQL Server 2008某数据库中有表SC(Sn0,Cn0,Grade),其中Grade列的类型为int。若在查询成绩时,希望将成绩按“优”、“良”、“中”、“及格”和“不及格”形式显示,则下列Case函数中正确的是( )。

A.Case GradeWhen Grade between 90 and 100 THEN Grade=ˊ优ˊWhen Grade between 80 and 89 THEN Grade=ˊ良ˊWhen Grade between 70 and 79 THEN Grade=ˊ由ˊWhen Grade between 60 and 69 THEN Grade=ˊ及格ˊElse Grade=ˊ不及格ˊEnd

B.Case GradeWhen Grade between 90 and 100 THEN ˊ优ˊWhen Grade between 80 and 89 THEN ˊ良ˊWhen Grade between 70 and 79 THENˊ中ˊWhen Grade between 60 and 69 THENˊ及格ˊElseˊ不及格ˊEnd

C.CaseWhen Grade between 90 and 100 THEN Grade=ˊ优ˊWhen Grade between 80 and 89 THEN Grade=ˊ良ˊWhen Grade between 70 and 79 THEN Grade=ˊ由ˊWhen Grade between 60 and 69 THEN Grade=ˊ及格ˊElse Grade=ˊ不及格ˊEnd

D.CaseWhen Grade between 90 and 100 THENˊ优ˊWhen Grade between 80 and 89 THEN ˊ良ˊWhen Grade between 70 and 79 THEN ˊ由ˊWhen Grade between 60 and 69 THEN ˊ及格ˊElseˊ不及格ˊEnd

参考答案
正确答案:D
此题考察了SQL中CASEWHEN语句的用法。如果是简单的赋值查询,比如数据库表示性别:1表示男,2表示女。则用CASEsexWhenˊ1ˊTHENˊ勇ˊWhenˊ2ˊTHENˊ女ˊELSEˊ其它ˊEND即可以表示。但如果条件较为复杂或包含判断式等,则用D所表示的方式。
看了设在SQL Server 20...的网友还看了以下: