Can anyone tell me why this always return 1? Thanks!
CREATE FUNCTION passrate(date, date, text) RETURNS float AS '
DECLARE
begindate ALIAS FOR $1;
enddate ALIAS FOR $2;
passfail ALIAS FOR $3;
ret float;
countp float;
counttotal float;
BEGIN
SELECT INTO countp COUNT(*)
FROM benchmark
WHERE passfail = passfail;
SELECT INTO counttotal COUNT(*)
FROM benchmark;
ret := countp / counttotal;
RETURN ret;
END;'
LANGUAGE 'plpgsql';
John