功能如下:
delimiter |
create function average() returns int
begin
declare AB int;
set AB= avg(attribute1) from tablename where attribute2='AMG' ;
return AB;
end;
|
ERROR No query specified
我做错了什么?
答案 0 :(得分:1)
试试这个:
DELIMITER |
CREATE FUNCTION average()
RETURNS INT
BEGIN DECLARE AB INT;
SELECT AVG(attribute1) INTO AB FROM tablename WHERE attribute2='AMG' ;
RETURN AB; END; |