0

I found a sql server code than i want to use on mysql. But i have this error. Anyone can help? I'll try everything, select into but still not working

CREATE FUNCTION udf_NORMDIST (v      FLOAT,
                                     mean        FLOAT,
                                     sigma       FLOAT,
                                     cummulative int)
RETURNS NUMERIC(28,8)


BEGIN


 SELECT @x = (v-mean)/sigma;

IF (cummulative = 1) then
   SELECT @z   = abs(@x)/sqrt(2.0);
   SELECT @t   = 1.0/(1.0+0.5*@z);
   SELECT @ans = @t*exp(-@z*@z-1.26551223+@t*(1.00002368+@t*(0.37409196+@t*(0.09678418+@t*(-0.18628806+@t*(0.27886807+@t*(-1.13520398+@t*(1.48851587+@t*(-0.82215223+@t*0.17087277)))))))))/2.0;

   IF @x <= 0 then
    return @ans;
   ELSE
    return  1-@ans;
   END if;
ELSE
   return  exp(-@x*@x/2.0)/sqrt(2.0*3.14159265358979);
END if;

END

0 Answers0