mysql function syntax no query specified

Viewed 2560

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?

1 Answers
Related