From: | Otniel Michael <otmic_ie(at)yahoo(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | About Div |
Date: | 2006-07-25 07:57:26 |
Message-ID: | 20060725075726.47735.qmail@web53211.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Aaron Bono | 2006-07-25 15:00:35 | Re: About Div |
Previous Message | Stephan Szabo | 2006-07-24 22:04:47 | Re: CREATE TABLE AS inside of a function |