SQL Modeling - Factorial Computation

  SELECT val-1 val, s factorial FROM DUAL
    MODEL RETURN ALL ROWS
    DIMENSION BY ( 0 d )
    MEASURES ( 0 s, 0 as val )
    RULES ITERATE (14) (
     s[iteration_number] = DECODE(iteration_number,0,1, iteration_number * s[iteration_number-1]),
    val[iteration_number] = iteration_number+1);

Back

  1424