Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: factorial

Re: factorial

From: --CELKO-- <71062.1056_at_compuserve.com>
Date: 20 Jan 2002 19:37:36 -0800
Message-ID: <c0d87ec0.0201201937.2ee48b00@posting.google.com>


>> 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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US