Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: aggregate and update
Jan van Veldhuizen (jan_at_van-veldhuizen.nl) wrote:
: I am trying to update a table with aggregate values without creating a view.
: I am having more complicated tables, but I will show what am doing with some
: simple tables:
: create table counters (name varchar(10), cnt int);
: create table test (name varchar(10), val int);
: insert into counters values('john', 0);
: insert into counters values('peter', 0);
: insert into counters values('david', 0);
: insert into test values('john', 1);
: insert into test values('john', 3);
: insert into test values('peter', 10);
: I want to calculate the sum of the val column and store it in the cnt column
: of the counters table.
: And I want the cnt value of David to remain zero, and not nullified because
: it does not exists in the test table.
Can't you simply use NVL to convert null sums to zero?
-- This space not for rent.Received on Thu Feb 03 2005 - 18:38:52 CST