Achieving ordered update
Achieving ordered update
От:
Allan Kamau <kamauallan@gmail.com>
Дата:
Hi, A classic problem. I would like to assign integer values (from a sequence) to records in a table based on the order (of contents) of other field(s) in the same table. I come across the solution before but I simply may not recall and a search returns no clues. Please point me to a resource with this solution. Allan.
Re: Achieving ordered update
От:
Thom Brown <thombrown@gmail.com>
Дата:
On 25 March 2010 12:02, Allan Kamau <kamauallan@gmail.com> wrote:
Rank and a window function?Hi,
A classic problem. I would like to assign integer values (from a
sequence) to records in a table based on the order (of contents) of
other field(s) in the same table.
I come across the solution before but I simply may not recall and a
search returns no clues. Please point me to a resource with this
solution.
Allan.
-
http://www.postgresql.org/docs/8.4/static/functions-window.html
http://www.postgresql.org/docs/8.4/static/tutorial-window.html
Thom
Re: Achieving ordered update
От:
Bopolissimus Platypus Jr <bopolissimus.lists@gmail.com>
Дата:
On Fri, Mar 26, 2010 at 1:02 AM, Allan Kamau wrote: > A classic problem. I would like to assign integer values (from a > sequence) to records in a table based on the order (of contents) of > other field(s) in the same table. Do you have a simple example? (create table, insert some data, then show what the output should look like, or what the data would look like after a transformation that would set the integer value from that sequence. do you mean to set a column in that row with that "integer value (from a sequence)"? or will you be filling a column in some other table with that "integer value..."? what is the function for determining the integer value based on the input data? In fact, what is the input data: do you mean "other field(s) in the same *row*" or do you really mean "table" in that sentence? is your function guaranteed to never have collisions (two rows requiring the same integer)? if there are collisions, how do you handle them? The "problem" isn't specified completely enough for me (probably others too, although one or two might have a hint if they've solved something similar already and so will have enough context to deduce what you mean) to even gain a mental model of just what you're trying to solve. tiger -- Gerald Timothy Quimpo http://bopolissimus.blogspot.com bopolissimus.lists@gmail.com bopolissimus@gmail.com Public Key: "gpg --keyserver pgp.mit.edu --recv-keys 672F4C78"