Re: SQL-puzzle
From: Arjan van Bentem <avbentem_at_DONT-YOU-DAREdds.nl>
Date: Sat, 5 Dec 1998 09:57:03 +0100
Message-ID: <74ash1$odj$1_at_newton.a2000.nl>
);
Date: Sat, 5 Dec 1998 09:57:03 +0100
Message-ID: <74ash1$odj$1_at_newton.a2000.nl>
Steinar Nyberg wrote
>This result I'll insert in the Totals-table, in the correct row (the
>product+ service combination must correspond to
>prod. + service from the Case-table)
A subquery will do the job. You do not really need the use the alias "tot" for table totals:
update totals tot
set solved_num =
( select count(*)
from case where product_num = tot.product_num and service_num = tot.service_num
);
Note that solved_num will be set to zero (instead of null) when no corresponding rows are found in table case. If you do not want that, then in the subquery use
decode( count(*), 0, to_number(null), count(*) )
Arjan. Received on Sat Dec 05 1998 - 09:57:03 CET