Re: sql
Date: 1995/10/23
Message-ID: <james.lawrence.114.000E512D_at_epamail.epa.gov>#1/1
Create a view for the first statement, then select against the view to get the sum.
In article <45o2lp$808_at_wn1.sci.kun.nl> jhr_at_sci.kun.nl (J.Reulen) writes:
>From: jhr_at_sci.kun.nl (J.Reulen)
>Subject: sql
>Date: Sat, 14 Oct 1995 09:16:55 GMT
>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 Mon Oct 23 1995 - 00:00:00 CET