Jeff Davis wrote:
> On Mon, 2008-01-21 at 14:25 -0500, Rhys Stewart wrote:
>
>> ok, let me clarify, dont want to remove them just want them changed
>> but need to keep the uid. However, I would like just one somevalue to
>> remain the same. so for example, uids, 2,4 and 8 have somevalue 44,
>> after i would like 2 to remain 44 but uids 4 and 8 would be changed.
>>
>
> Can you explain why you're trying to do this? It's a very unusual
> requirement.
>
> That being said, the query would look something like this:
>
> (SELECT MIN(uid) AS uid, somevalue FROM mytable GROUP BY somevalue)
> UNION
> (SELECT uid, somevalue + random() AS somevalue
> FROM mytable WHERE uid NOT IN
> (SELECT MIN(uid)
> FROM mytable GROUP by somevalue)
>
> Disclaimer: I haven't actually tested this query, but it looks about
> right.
>
How can you garantee that "somevalue + random()" won't duplicate other
unique values in this column? ;)
> Regards,
> Jeff Davis
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
--
Andrei Kovalevski
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, ODBCng - http://www.commandprompt.com/