啦啦啦啦員工工資合計程式碼

daqianmen發表於2021-09-09
set serveroutput on; declare cursor cdept is select deptno from dept; pdeptno dept.deptno%type; cursor cemp(dno number) is select sal from emp where deptno=dno; psal emp.sal%type; count1 number; count2 number ; count3 number; totalsal number; begin open cdept; loop fetch cdept into pdeptno; exit when cdept%notfound; count1:=0;count2:=0;count3:=0;totalsal:=0; open cemp(pdeptno); loop fetch cemp into psal; exit when cemp%notfound; if psal = 3000 and psal  6000 then count3:=count3+1; end if; totalsal:=totalsal+psal; end loop; insert into test values(pdeptno,count1,count2,count3,totalsal); close cemp; end loop; close cdept; dbms_output.put_line('完成'); commit; end;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/1727/viewspace-2798447/,如需轉載,請註明出處,否則將追究法律責任。

相關文章