Re: [Q] Sorting a column

From: DA Morgan <damorgan_at_psoug.org>
Date: Thu, 07 Aug 2008 16:21:55 -0700
Message-ID: <1218151307.296349@bubbleator.drizzle.com>


digory wrote:
> 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.)

NAME is a reserved word ... rename your column

-- 
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan_at_x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Thu Aug 07 2008 - 18:21:55 CDT

Original text of this message