Question

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?

Was it helpful?

Solution

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; |
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top