编写一个PL SQL块,要求将EMP表中部门编号=30的员工的薪资进行统计

,要求对该部门最高薪水--最低薪水之差进行判断
如果差距大于等于2000,输出标记‘H’
如果差距小于2000,大于等于1000,输出标记‘M’
如果差距小于1000,输出标记‘L’
(2)、在1的基础上,用CASE实现
如果标记为‘H’,输出员工工资超过2000
如果标记为‘M’,输出员工工资在1000---2000之间
如果标记为‘L’,输出员工工资在1000以内

第1个回答  2014-05-12
declare
type emp_cursor_type is ref cursor;
emp_cursor1 emp_cursor_type;
emp_cursor2 emp_cursor_type;
emp_sal emp.sal%type;
emp_deptno emp.deptno%type;
begin
open emp_cursor1 for
select distinct deptno from emp;
LOOP
fetch emp_cursor1
into emp_deptno;
exit when emp_cursor1%notfound;
open emp_cursor2 for
select max(sal)-min(sal) sal from emp
where deptno=emp_deptno
group by deptno;

fetch emp_cursor2 into emp_sal;
if emp_sal>=2000
then dbms_output.put_line('部门'||emp_deptno||':'||'H');
elsif 1000<=emp_sal and emp_sal<2000
then dbms_output.put_line('部门'||emp_deptno||':'||'M');
else dbms_output.put_line('部门'||emp_deptno||':'||'L');
end if;

end loop;
end;
第2问没明白什么意思;标记又不在表里面,只是输出而已。而且上一个标记是部门的工资差,和个人工资又没必然联系。
相似回答