为什么初始值是0,然后每个+1后输出的结果成这样的呢
set serveroutput on
delcare
begin
cursor cemp is select to char(hiredate,'yyyy') from emp;
pdiredate vachar2(4);
count80 number=0;
count81 number=0;
count82 number=0;
打开光标
open emp;
循环
loop
fetch cemp into phiredate;
exit when cemp%notfound;
判断如实年份
if phiredate='1980' then count80=count80+1;
elsif phiredate='1981' then count81=count81+1;
elsif phiredate='1982' then count82=count82+1;
else phiredate='1987' then count87=count87+1;
end if;
end loop;
关闭关闭
close emp;
dbms_output.put_line("Total":||(count80+count81+count82+count87));
dbms_output.put_line(1980:||count80);
dbms_output.put_line(1981:||count81);
dbms_output.put_line(1982:||count82);
dbms_output.put_line(1987:||count87);
end;