Search Postgresql Archives

Re: (un)grouping question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 21, 2008 1:45 PM, Scott Marlowe <scott.marlowe@xxxxxxxxx> wrote:
> On Jan 21, 2008 11:36 AM, Rhys Stewart <rhys.stewart@xxxxxxxxx> wrote:
> > Hi list,
> >
> > have the following table
> >
> > uid|somevalue
> > --------------------
> > 1|11
> > 2|44
> > 3|31
> > 4|44
> > 5|71
> > 6|33
> > 7|33
> > 8|44
> > 9|14
> >
> > would like to remove the duplicate values in the column somevalue. doing
> > this by just adding a random number  is perfectly fine, however i want to
> > retain at least one of the original values of somevalue. Any ideas how to do
> > this in in a query?
>
> I can get you halfway there.  You want a query something like this to
> identify all but one of the values:
>
> select a.uid from sometable a left join sometable b on
> (a.somevale=b.somevalue and a.uid > b.uid)
>
> From there, you'll have to figure out the update part of problem. :)

Oh yea, you might need a distinct in that select query.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux