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
已采納回答 / 昕牌肉貓
自己的親身經(jīng)歷:win10 64bit,裝了11.2g的Oracle 64bit,無(wú)論怎么調(diào)(下載64bit的SQL developer也沒用),都無(wú)法調(diào)通SQL developer,感覺是32與64之間的兼容問題。win7 32bit,裝了11.2g的Oracle 32bit,很輕松就用上了SQL developer(注意要選一下java的位置,在Oracle目錄里的一個(gè)jdk的文件夾里面找)。我使用PL/SQL developer客戶端學(xué)習(xí)的這門課程,除了一些命令不能用(如accept、servero...
2017-08-18
如果是在pl/sql developer中編譯的話,只能在sql窗口中:
DECLARE
pnum number:= &num;
BEGIN
if pnum = 0 then
dbms_output.put_line('數(shù)字是0');
elsif pnum = 1 then
dbms_output.put_line('數(shù)字是1');
elsif pnum = 2 then
……
請(qǐng)忽略accept命令,不支持。set serveroutput on也不支持。
DECLARE
pnum number:= &num;
BEGIN
if pnum = 0 then
dbms_output.put_line('數(shù)字是0');
elsif pnum = 1 then
dbms_output.put_line('數(shù)字是1');
elsif pnum = 2 then
……
請(qǐng)忽略accept命令,不支持。set serveroutput on也不支持。
2017-08-17
已采納回答 / qq_aiq_2
if pjob='PRESIDENT' then update sal=sal+1000; 后面不加where 約束 會(huì)刷新表中所有數(shù)據(jù),前面的if條件 與后面執(zhí)行語(yǔ)句沒關(guān)系的
2017-08-16
set serveroutput on
accept num prompt '請(qǐng)輸入數(shù)字';
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('輸入了其他數(shù)字');
end if;
end;
/
accept num prompt '請(qǐng)輸入數(shù)字';
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('輸入了其他數(shù)字');
end if;
end;
/
2017-08-09
最新回答 / 蒲公英0910
group by后面要加變量名,會(huì)造成每個(gè)值的數(shù)量統(tǒng)計(jì),而不能按照變量值區(qū)間分段統(tǒng)計(jì)
2017-08-04