Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to add and populate a new column?
On Tue, 10 Dec 1996 15:37:34 GMT, zlm101_at_psu.edu (Z. Martinez) wrote:
>I need to add a new column, called rank, in a table called customers.
>The "rank" column depends on another column called quantity.
>So, the row that has the highest "quantity" value gets a "rank" value
>of 1, and the lowest quantity value gets the last rank.
alter table customers
add (rank number(10)); -- or whatever size declare
seq number := 0;
begin
for rec in (
select rowid as line from customers order by quantity desc ) loop seq := seq + 1; update customers set rank = seq where rowid = rec.line ;
modify (rank not null); -- if you want to
-- Zev Sero Don't blame me, I voted for Harry Browne zsero_at_mail.idt.net zsero_at_technimetrics.comReceived on Tue Dec 10 1996 - 00:00:00 CST
![]() |
![]() |