Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL-puzzle
A copy of this was sent to "Steinar Nyberg" <sn2_at_storebrand.no>
(if that email address didn't require changing)
On 3 Dec 1998 10:36:00 GMT, you wrote:
>I have to tables.
>
>Table Totals :
>week_num, product_num, service_num, solved_num
>
>This table allready contains the total number of cases called in to the
>help-desk for a all combinations of products and services for each week.
>The column solved_num is empty
>
>
>Table Case :
>opened_dat, product_num, service_num, solved_bln
>
>This table contains one row for each case called in to the help-desk.
>
>
>
>
>My problem :
>For each week I want to count the number of solved cases for each
>combination of product and service (from the Case-table).
>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)
>
sounds more like you want to update not insert. If so:
update tableTotals
set solved_num = ( select count(*)
from tableCase where tableCase.product_num = tableTotals.product_num and tableCase.service_num = tableTotals.service_num and to_number(to_char(tableCase.opened_dat,'IW')) = tableTotals.week_num )/
that will take each row in the tableTotals table and run a query for it, that query will find for that product_num and service_num the count of rows in tableCase for the given week....
>How do I solve this problem, using a single SQL-string ?
>
>
>Thank you !
>
>
>Steinar
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
--
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu Dec 03 1998 - 21:40:41 CST
![]() |
![]() |