Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Renumber a set of grupped rows?

Re: Renumber a set of grupped rows?

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Wed, 21 Jan 2004 08:14:26 -0800
Message-ID: <F001.005DDC49.20040121081426@fatcity.com>

Although you've had a row-at-a-time version from someone, you might try something like the following if you can't do a "create as select" to rebuild the original data.

Create table temp
pctfree 0
nologging
as
select

        rowid    e_rowid,
        row_number() over (PARTITION BY DEPTNO order by deptno) x 
from emp;

create unique index t_i on temp(e_rowid); alter table temp modify e_rowid not null;

update emp e
set

    req_id = (

        select x from temp t
        where t.e_rowid = e.rowid

    );

(Just making it up as I go along, so I won't guarantee that it works).

Regards

Jonathan Lewis
http://www.jlcomp.demon.co.uk

  The educated person is not the person   who can answer the questions, but the   person who can question the answers -- T. Schick Jr

Next public appearance2:
 March 2004 Hotsos Symposium - Keynote
 March 2004 Charlotte NC - OUG Tutorial
 April 2004 Iceland

One-day tutorials:
http://www.jlcomp.demon.co.uk/tutorial.html

Three-day seminar:
see http://www.jlcomp.demon.co.uk/seminar.html ____UK___February

The Co-operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html

> Just out of curiocity, and while I am trying to learn about Row_NUMBER(),
> how would you code the following to do an update on the 2nd column?
>
> >select deptno, row_number() over (PARTITION BY DEPTNO order by deptno) x
> >from emp
>
> thx
> maa

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jonathan Lewis
  INET: jonathan_at_jlcomp.demon.co.uk

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Jan 21 2004 - 10:14:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US