X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 95A239FB0D1 for ; Tue, 25 Jul 2006 06:03:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 19344-03-8 for ; Tue, 25 Jul 2006 09:03:19 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web53211.mail.yahoo.com (web53211.mail.yahoo.com [206.190.49.81]) by postgresql.org (Postfix) with SMTP id DAD639FB21E for ; Tue, 25 Jul 2006 04:57:27 -0300 (ADT) Received: (qmail 47740 invoked by uid 60001); 25 Jul 2006 07:57:26 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=JfQ8lYl6HsAZ9RGbXzqIsnPF9DOFm98EUqCPJ1+sA9EOHq/+QnmymzHLAaE74w9M/K7WO2TLd6BlKSKPPUtqrC/u35ZFWI4AKUAm96SRcVifmdxjRgdQ0qJsYmtDcW2rtVDh1xZLi6f+uJ+NhmbXxZW5hlI2juAZVhfnMXJgNoU= ; Message-ID: <20060725075726.47735.qmail@web53211.mail.yahoo.com> Received: from [222.124.227.96] by web53211.mail.yahoo.com via HTTP; Tue, 25 Jul 2006 00:57:26 PDT Date: Tue, 25 Jul 2006 00:57:26 -0700 (PDT) From: Otniel Michael Subject: About Div To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-2064587780-1153814246=:47448" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.356 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS, HTML_MESSAGE X-Spam-Level: *** X-Archive-Number: 200607/306 X-Sequence-Number: 25880 --0-2064587780-1153814246=:47448 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Dear All, I have a problem with this case : I have 10 candy for 7 child (A, B, C, D, E, F, G). Table X : code value ------- -------- A 0 B 0 C 0 D 0 E 0 F 0 G 0 And I want divide it with this algorithm : A = 10 / 7 = 1 B = (10-1) / (7-1) = 9 / 6 = 1 C = (10-2) / (7-2) = 8 / 5 = 1 D = (10-3) / (7-3) = 7 / 4 = 1 E = (10-4) / (7-4) = 6 / 3 = 2 F = (10-6) / (7-5) = 4 / 2 = 2 G = (10-8) / (7-6) = 2 / 2 = 2 In my first solution i use loop - for each record in my function. But it is too slow in a lot of data. Did postgresql have a function for my case? Thanks All. -- "He who is quick to become angry will commit folly, and a crafty man is hated" --------------------------------- Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail Beta. --0-2064587780-1153814246=:47448 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Dear All,

I have a problem with this case :

I have 10 candy for 7 child (A, B, C, D, E, F, G).

Table X :
code   value
 -------  --------
 A        0       
 B        0       
 C        0       
 D        0       
 E        0       
 F        0       
 G       0       

And I want divide it with this algorithm :
    A = 10 / 7 = 1
    B = (10-1) / (7-1) = 9 / 6 = 1
    C = (10-2) / (7-2) = 8 / 5 = 1
    D = (10-3) / (7-3) = 7 / 4 = 1
    E = (10-4) / (7-4) = 6 / 3 = 2
    F = (10-6) / (7-5) = 4 / 2 = 2
    G = (10-8) / (7-6) = 2 / 2 = 2

In my first solution i use loop - for each record in my function.
But it is too slow in a lot of data.
Did postgresql have a function for my case?

Thanks All.


--
"He who is quick to become angry will commit folly, and a crafty man is hated"


Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail Beta. --0-2064587780-1153814246=:47448--