Reputation: 53
the function is this:
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
What i do wrong?
Upvotes: 4
Views: 2784
Reputation: 29051
Try this:
DELIMITER |
CREATE FUNCTION average()
RETURNS INT
BEGIN DECLARE AB INT;
SELECT AVG(attribute1) INTO AB FROM tablename WHERE attribute2='AMG' ;
RETURN AB; END; |
Upvotes: 1