From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | Rhys Stewart <rhys(dot)stewart(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: (un)grouping question |
Date: | 2008-01-21 19:50:11 |
Message-ID: | 1200945011.10057.516.camel@dogma.ljc.laika.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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.
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | Christian Schröder | 2008-01-21 20:01:09 | Re: Views and permissions |
Previous Message | Andrei Kovalevski | 2008-01-21 19:49:10 | Re: (un)grouping question |