[Q] Sorting a column

From: digory <digory_at_gmx.net>
Date: Thu, 7 Aug 2008 01:07:15 -0700 (PDT)
Message-ID: <1210a149-d43e-48a8-bbd7-9a688c96fa88@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.) Received on Thu Aug 07 2008 - 03:07:15 CDT

Original text of this message