日期:2014-05-17  浏览次数:21060 次

求一个 判断成绩 效率的算法
4.有一张表,里面有3个字段:语文,数学,英语。其中有3条记录分别表示语文70分,数学80分,英语58分,请用一条sql语句查询出这三条记录并按以下条件显示出来(并写出您的思路):  
   大于或等于80表示优秀,大于或等于60表示及格,小于60分表示不及格。  
       显示格式:  
       语文              数学                英语  
       及格              优秀                不及格    





这里是数据库操作
create table t4(
yw number,
sx number,
yy number);

insert into t4 values(70,80,58);

select (case when t4.yw>=80 then '优秀'
             when t4.yw>=60 then '及格'
             else '不及格' end)as 语文,
       (case when t4.sx>=80 then '优秀'
             when t4.sx>=60 then '及格'
             else '不及格' end)as 数序,
       (case when t4.yy>=80 then '优秀'
             when t4.yy>=60 then '及格'
             else '不及格' end)as 英语
from t4;


这是我写的 但是效率低  请教各位 怎么写 能效率高点
算法 数据库 sql

------解决方案--------------------
这样写差不多了吧,效率有多慢?你有多少数据?