I've had a go at this from another angle, trying to do it all in a SQL statement (using your table testTbl and the column numbers).
Up vote 1 down vote favorite share g+ share fb share tw.
I have a table which has a column call numbers Numbers ------ 3 5 I am trying to get the factorial of those. I am using the below logic but not with proper result Select Numbers ,EXP(SUM(LN(Numbers)) OVER (ORDER BY Numbers)) Factorial FROM testTbl *Output * Numbers Factorial ------ --------- 3 3.00000000000000000000000000000000000001 5 15.0000000000000000000000000000000000002 What is wrong? Please help Expected -------- Numbers Factorial ------ --------- 3 6 5 120 Thanks in advance oracle oracle10g link|improve this question edited Nov 18 '11 at 14:49Ollie5,3551320 asked Nov 18 '11 at 12:16user10259012218 97% accept rate.
1 look at this article – igor milla Nov 18 '11 at 13:06.
I've had a go at this from another angle, trying to do it all in a SQL statement (using your table testTbl and the column numbers). This is what I've come up with, see if it suits you: SELECT testtbl. Numbers, ROUND( EXP( SUM( LN( t1.
N ) ) ) ) AS factorial FROM ( SELECT UNIQUE LEVEL n FROM testtbl CONNECT BY LEVEL N = testTbl. Numbers GROUP BY testtbl. Numbers ORDER BY testtbl.
Numbers; Gives the output: Numbers Factorial 3 6 5 120 Hope it helps...
Were it me, I'd create a factorial function and call that user-defined function in my query. Something like SQL> create function factorial( p_n in number ) 2 return number 3 is 4 begin 5 if( p_n = 1 ) 6 then 7 return p_n; 8 else 9 return p_n * factorial( p_n - 1 ); 10 end if; 11 end; 12 / Function created. SQL> with t as ( 2 select 3 num from dual 3 union all 4 select 5 from dual 5 ) 6 select num, 7 factorial(num) 8 from t; NUM FACTORIAL(NUM) ---------- -------------- 3 6 5 120 If for some reason you cannot define a new function and you really want to do it in SQL, you'll can generate all the numbers less than the number in your table and then aggregate those generated numbers.
SQL> ed Wrote file afiedt. Buf 1 with t as ( 2 select 3 num from dual 3 union all 4 select 5 from dual 5 ) 6 select t. Num, 7 exp( sum(ln(gen.
Num))) factorial 8 from (select level num 9 from dual 10 connect by level / NUM FACTORIAL ---------- ---------- 5 120 3 6.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.