From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Richard Huxton <dev(at)archonet(dot)com> |
Cc: | gry(at)ll(dot)mit(dot)edu, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: tid_le comparison for tuple id (ctid) values? |
Date: | 2005-11-22 09:29:06 |
Message-ID: | 4382E4E2.2050601@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Richard Huxton wrote:
> george young wrote:
>
>> Well, I don't have any need for it to correlate with the age of the
>> tuple. My use of step.ctid<s.ctid was not to get the earliest or
>> latest row, but just to *choose* one. Perhaps there's some other
>> query that would modify only one of each pair of equal-keyed rows?
>
>
> How do you know there is only 1 duplicate?
>
> Anyway, if (x,y) are the same but (z) is not then you can compare
> against max(z) or min(z). Something like:
>
> SELECT t1.x AS update_me_x, t1.y AS update_me_y, t1.z AS update_me_z
> FROM
> test_tbl AS t1,
> (
> SELECT x,y,max(z) AS max_z
> FROM test_tbl
> GROUP BY x,y
> ) AS t2
> WHERE
> t1.x = t2.x AND t1.y = t2.y AND t1.z = t2.max_z
Oh, of course the easiest way to do it is to add an additional column of
type SERIAL to your temp-table. That way you have your rows nicely
numbered as you import them.
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Grigory O. Ptashko | 2005-11-22 10:10:29 | Re: Please help to wite the constraint. |
Previous Message | Richard Huxton | 2005-11-22 09:14:04 | Re: tid_le comparison for tuple id (ctid) values? |