- table st(sid int,sname varchar2(10),total int,grade varchar(2))
我的代码如下。
declare
totsum number;
average number;
procedure sumavg(x out number, y out number) is
begin
select sum(total) into x, avg(total) into y from st;
end;
begin
sumavg(totsum,average);
dbms_output.put_line('Sum: '||totsum||' Average: '||average);
end;
/
这给出了错误:
ORA-06550: line 6, column 31:
PL/SQL: ORA-00934: group function is not allowed here
ORA-06550: line 6, column 5:
PL/SQL: SQL Statement ignored
4. procedure sumavg(x out number, y out number) is
5. begin
6. select sum(total) into x, avg(total) into y from st;
7. end;
8.
我需要显示值totsum和average。请帮助修正代码。谢谢。
答案 0 :(得分:1)
在第6行,select..into
应为:
select sum(total), avg(total) into x,y from st;