sql

From: J.Reulen <jhr_at_sci.kun.nl>
Date: 1995/10/14
Message-ID: <45o2lp$808_at_wn1.sci.kun.nl>#1/1


I need help to accomplish a sql-script that will give the following result :

A have a table ABC:

 Name                      Type
 -----------------------------------
 A                             VARCHAR2(5)
 B                             DATE
 C                             NUMBER

The contents of the table is :

table1:

A     B                       C

----- --------- ---------
A 01-JAN-95 .3 A 01-JAN-95 .25 A 02-JAN-95 .25 A 02-JAN-95 .1 B 01-JAN-95 .5 B 01-JAN-95 .25 B 02-JAN-95 .25 B 02-JAN-95 .6

I have to calculate first the total of C per A per B The result would be:

table2:

A     B                       C

----- --------- ---------
A 01-JAN-95 .55 A 02-JAN-95 .35 B 01-JAN-95 .75 B 02-JAN-95 .85

Then I have to round these totals on quaters the result would be:

table3:

A     B                       C

----- --------- ---------
A 01-JAN-95 .5 A 02-JAN-95 .25 B 01-JAN-95 .75 B 02-JAN-95 .75

so far I can realise this whit de scl-script:

SELECT A, ROUND(SUM(C)*4)/4
FROM ABC
GROUP BY A, B
ORDER BY A; The final result must be to total of C of table 1 per A the result would be:

table4:

A     B                       C

----- --------- ---------
A 01-JAN-95 .75 B 01-JAN-95 1,5

The sql-script to realize this result (table4) I can't figure out.

Has anyone a suggestion?

Guido Reulen. Received on Sat Oct 14 1995 - 00:00:00 CET

Original text of this message