zoukankan      html  css  js  c++  java
  • oracle 统计成绩

    set serveroutput on;
    
    declare
    
    cursor c1 is select dno,dname from dep;
    
    pdno dep.dno%TYPE;
    
    pdname dep.dname%type;
    
    cursor c2(aa varchar2,bb number) is select grade from sc where cno=(select cno from course where cname=aa)
    
    and sno in (select sno from student where dno=bb);
    
    pgrade sc.grade%type;
    
    count1 number;count2 number;count3 number;avgg number;
    
    coursename varchar2(100):='大学物理';
    
    begin
    
    open c1;
    
    loop
    
    fetch c1 into pdno,pdname;
    
    exit when c1%notfound;
    
    count1 :=0;count2 :=0;count3 :=0;
    
    select avg(grade) into avgg from sc where cno=(select cno from course where cname=coursename)
    
    and sno in (select sno from student where dno=pdno);
    
    open c2(coursename,pdno);
    
    loop
    
    fetch c2 into pgrade;
    
    exit when c2%notfound;
    
    if pgrade <60 then count1:=count1+1;
    
    elsif pgrade >60 and pgrade <=80 then count2:=count2+1;
    
    else count3:=count3+1;
    
    end if;
    
    end loop;
    
    close c2;
    
    insert into msg values (coursename,pdname,count1,count2,count3,avgg);
    
    end loop;
    
    close c1;
    
    dbms_output.put_line('统计完成');
    
    end;
    
    /
  • 相关阅读:
    MyBatis
    spring post 图片
    spring boot
    linux 调用栈打印
    sys.usb.config webcam
    jsp+bean+servlet 案例代码
    常见的http头信息
    通过JSTL+EL实现循环迭代
    EL表达式介绍
    EL表达式
  • 原文地址:https://www.cnblogs.com/wangchuanfu/p/10988587.html
Copyright © 2011-2022 走看看