| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: factorial
>> I'm not sure I understand section #3 in your message. Don't you
want
to create a factorial table with _two_ columns? Didn't you also forget
to "group by"? <<
That was bad. Here is tested code in SQL Server. Notice that it does
not have
a LN() function and I have to use CEILING() to get the right answers
because of floating point rounding errors
CREATE TABLE Factorials (seq INTEGER NOT NULL, fact INTEGER NOT NULL);
INSERT INTO Factorials VALUES (1, 0); INSERT INTO Factorials VALUES (2, 0); INSERT INTO Factorials VALUES (3, 0); INSERT INTO Factorials VALUES (4, 0); INSERT INTO Factorials VALUES (5, 0);
INSERT INTO Factorials
SELECT F1.seq, CAST ( CEILING(EXP(SUM(LOG(F2.seq))))AS INTEGER)
FROM Factorials AS F1, Factorials AS F2
WHERE F2.seq <= F1.seq
GROUP BY F1.seq;
>> Table of integers is so important that I use table function for it.
<<
This is very proprietary and Standard SQL has nothing like it at all. To be honest, I have never see this before. God! It is so .... procedural!! Received on Sun Jan 20 2002 - 21:37:36 CST
![]() |
![]() |