use this for POSTGRESQL:
-- Start
CREATE OR REPLACE FUNCTION stock.udf_NORMDIST(
value1 FLOAT,
mean float,
sigma float,
cummulative float )
RETURNS NUMERIC( 29,9 )
AS $total$
declare total integer;
DECLARE x FLOAT;
DECLARE z FLOAT;
DECLARE t FLOAT;
DECLARE ans FLOAT;
DECLARE returnvalue FLOAT;
BEGIN
select...