Hi I am working on an HR data warehouse that requires a factorial in one of the aggregates.
If you don't know, 7 factorial = 7 * 6 * 5 * 4 * 3 * 2 * 1
It also can be be written as 7!
I wrote a function to do this but I would rather use SQL if this is possible.
The function looks like :
FUNCTION fac (n POSITIVE) RETURN INTEGER IS -- returns n!
BEGIN
IF n = 1 THEN -- terminating condition
RETURN 1;
ELSE
RETURN n * fac(n - 1); -- recursive call
END IF;
END fac;
Thanks in advance for any suggestions
If you don't know, 7 factorial = 7 * 6 * 5 * 4 * 3 * 2 * 1
It also can be be written as 7!
I wrote a function to do this but I would rather use SQL if this is possible.
The function looks like :
FUNCTION fac (n POSITIVE) RETURN INTEGER IS -- returns n!
BEGIN
IF n = 1 THEN -- terminating condition
RETURN 1;
ELSE
RETURN n * fac(n - 1); -- recursive call
END IF;
END fac;
Thanks in advance for any suggestions