标签:har oop 统计 red cursor bsp not select code
1. 统计每年入职的员工人数
1 set SERVEROUTPUT ON; 2 declare 3 cursor cemp is select to_char(hiredate,‘yyyy‘) from emp; 4 phiredate VARCHAR2(4); 5 count80 number:=0; 6 count81 number:=0; 7 count82 number:=0; 8 count83 number:=0; 9 begin 10 open cemp; 11 loop 12 fetch cemp into phiredate; 13 exit when cemp%notfound; 14 if phiredate=‘1980‘ then count80:=count80+1; 15 elsif phiredate=‘1981‘ then count81:=count81+1; 16 elsif phiredate=‘1982‘ then count82:=count82+1; 17 else count83:=count83+1; 18 end if; 19 end loop; 20 close cemp; 21 dbms_output.put_line(‘total:‘||(count80+count81+count82+count83)); 22 end; 23 /
标签:har oop 统计 red cursor bsp not select code
原文地址:https://www.cnblogs.com/henn/p/12562779.html