Re: [Q] Sorting a column
Date: Fri, 8 Aug 2008 15:26:11 +0000 (UTC)
Shakespeare <whatsin_at_xs4all.nl> wrote:
> "digory" <digory_at_gmx.net> schreef in bericht
> > 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
Only if they're in a cluster - rows that have the same cluster key have the same ROWID (or so it says in the docs, I haven't tried it).
-- _______________________________________________________________________ Dan Blum tool_at_panix.com "I wouldn't have believed it myself if I hadn't just made it up."Received on Fri Aug 08 2008 - 10:26:11 CDT