select a.deptno ,
sum(case when sal<3000 then 1 else 0 end) ,
sum(case when sal<=6000 and sal>=3000 then 1 else 0 end) ,
sum(case when sal>6000 then 1 else 0 end) ,
nvl(sum(sal),0)
from dept a, emp b
where a.deptno = b.deptno(+)
group by a.deptno
order by a.deptno;
sum(case when sal<3000 then 1 else 0 end) ,
sum(case when sal<=6000 and sal>=3000 then 1 else 0 end) ,
sum(case when sal>6000 then 1 else 0 end) ,
nvl(sum(sal),0)
from dept a, emp b
where a.deptno = b.deptno(+)
group by a.deptno
order by a.deptno;
2017-08-24
declare
cursor cur is select empno,sal from emp order by sal;
pempno emp.empno%type;
psal emp.sal%type;
cnt number :=0;
acc emp.sal%type;
cursor cur is select empno,sal from emp order by sal;
pempno emp.empno%type;
psal emp.sal%type;
cnt number :=0;
acc emp.sal%type;
2017-08-24
begin
select sum(sal) into acc from emp;
open cur;
loop
exit when acc>50000;
fetch cur into pempno,psal;
exit when cur%notfound;
select sum(sal) into acc from emp;
open cur;
loop
exit when acc>50000;
fetch cur into pempno,psal;
exit when cur%notfound;
2017-08-24
if acc+psal*0.1<=50000 then
update emp set sal = sal*1.1 where empno=pempno;
cnt := cnt+1;
acc := acc+psal*0.1;
end if;
end loop;
dbms_output.put_line(cnt ||' '||acc);
close cur;
end;
/
update emp set sal = sal*1.1 where empno=pempno;
cnt := cnt+1;
acc := acc+psal*0.1;
end if;
end loop;
dbms_output.put_line(cnt ||' '||acc);
close cur;
end;
/
2017-08-24
已采纳回答 / 昕牌肉猫
自己的亲身经历:win10 64bit,装了11.2g的Oracle 64bit,无论怎么调(下载64bit的SQL developer也没用),都无法调通SQL developer,感觉是32与64之间的兼容问题。win7 32bit,装了11.2g的Oracle 32bit,很轻松就用上了SQL developer(注意要选一下java的位置,在Oracle目录里的一个jdk的文件夹里面找)。我使用PL/SQL developer客户端学习的这门课程,除了一些命令不能用(如accept、servero...
2017-08-18
如果是在pl/sql developer中编译的话,只能在sql窗口中:
DECLARE
pnum number:= &num;
BEGIN
if pnum = 0 then
dbms_output.put_line('数字是0');
elsif pnum = 1 then
dbms_output.put_line('数字是1');
elsif pnum = 2 then
……
请忽略accept命令,不支持。set serveroutput on也不支持。
DECLARE
pnum number:= &num;
BEGIN
if pnum = 0 then
dbms_output.put_line('数字是0');
elsif pnum = 1 then
dbms_output.put_line('数字是1');
elsif pnum = 2 then
……
请忽略accept命令,不支持。set serveroutput on也不支持。
2017-08-17
已采纳回答 / qq_aiq_2
if pjob='PRESIDENT' then update sal=sal+1000; 后面不加where 约束 会刷新表中所有数据,前面的if条件 与后面执行语句没关系的
2017-08-16
set serveroutput on
accept num prompt '请输入数字';
declare
pnum number:=&num;
begin
if pnum = 0 then dbms_output.put_line('输入了0');
elsif pnum = 1 then dbms_output.put_line('输入了1');
elsif pnum = 2 then dbms_output.put_line('输入了2');
else dbms_output.put_line('输入了其他数字');
end if;
end;
/
accept num prompt '请输入数字';
declare
pnum number:=&num;
begin
if pnum = 0 then dbms_output.put_line('输入了0');
elsif pnum = 1 then dbms_output.put_line('输入了1');
elsif pnum = 2 then dbms_output.put_line('输入了2');
else dbms_output.put_line('输入了其他数字');
end if;
end;
/
2017-08-09