Re: Sorting a column

From: <fitzjarrell_at_cox.net>
Date: Fri, 8 Aug 2008 06:35:00 -0700 (PDT)
Message-ID: <4cb5047a-3dff-46c8-925a-44b44c6c664a@i76g2000hsf.googlegroups.com>


On Aug 8, 1:58 am, "Shakespeare" <what..._at_xs4all.nl> wrote:
> "digory" <dig..._at_gmx.net> schreef in berichtnews:1210a149-d43e-48a8-bbd7-9a688c96fa88_at_y38g2000hsy.googlegroups.com...
>
>
>
>
>
> > Hi
>
> > I have a table T with two columns NAME (VARCHAR2) and POS (NUMBER). I
> > want to write an UPDATE query, which updates the column POS such that
> > its values correspond to the alphabetical order of NAME.
>
> > UPDATE
> >   T t1
> > SET pos = (SELECT ROWID FROM T t2 WHERE t1.NAME = t2.NAME ORDER BY
> > NAME)
>
> > That does not work, because the WHERE clause returns a single row,
> > which will always have a ROWID of 1.
>
> > How do I do this? (It's possible with a PROCEDURE, of course, but I
> > want to avoid them.)
>
> ROWID? Don't you mean rownum?
> I don't think tables will ever have rows with the same rowid (except by
> coincidence)
>
> Shakespeare- Hide quoted text -
>
> - Show quoted text -

Look again, it's the same table queried twice. The rowids WILL match up.

David Fitzjarrell Received on Fri Aug 08 2008 - 08:35:00 CDT

Original text of this message