maaf, sepertinya cara yg dijelaskan oleh pak wawan terlalu rumit.
sebaiknya gunakan tool sql yg sudah ada
contohnya seperti ini :
SQL> conn hr/[EMAIL PROTECTED]
Connected.
SQL> select department_id,job_id, sum(salary)
2 from employees
3 where department_id is not null
4 group by rollup(department_id,job_id);
DEPARTMENT_ID JOB_ID SUM(SALARY)
------------- ---------- -----------
10 AD_ASST 4400
10 4400
20 MK_MAN 13000
20 MK_REP 6000
20 19000
30 PU_MAN 11000
30 PU_CLERK 13900
30 24900
40 HR_REP 6500
40 6500
50 ST_MAN 36400
50 SH_CLERK 64300
50 ST_CLERK 55700
50 156400
60 IT_PROG 28800
60 28800
70 PR_REP 10000
70 10000
80 SA_MAN 61000
80 SA_REP 243500
80 304500
DEPARTMENT_ID JOB_ID SUM(SALARY)
------------- ---------- -----------
90 AD_VP 34000
90 AD_PRES 24000
90 58000
100 FI_MGR 12000
100 FI_ACCOUNT 39600
100 51600
110 AC_MGR 12000
110 AC_ACCOUNT 8300
110 20300
684400
31 rows selected.
SQL>
Pada tanggal 04/05/07, wawan mulyawan2 <[EMAIL PROTECTED]>
menulis:
>
> Caranya bisa dengan 2 cara: tergantung kebutuhannya.
>
> 1. dengan cursor lagi dengan menambahkan syntax group by sehingga
> query cursornya menjadi
>
> select sum ((C*(D/100)) * B) sub total from x
>
> group by a
>
> 2. dengan menggunakan plsql programming. Pastikan query cursornya sudah
> di order by a
>
> lbl1 :='';
>
> subtotal := 0;
>
> open cursor_x;
>
> loop
>
> fetch cursor_x into record_x;
>
> exit when cursor_x%notfound;
>
> if record_x.a <> lbl1 then
>
> dbms_output.put_line('subtotal '||subtotal);
>
> lbl1 := record_x.a;
>
> subtotal := 0;
>
> end if;
>
> subtotal := subtotal + ((C*(D/100)) * B);
>
> end loop;
>
> mungkin bsegitu sajah
>
> ti
>
> mulyawan
>
> semoga membantu
>
> -----Original Message-----
> From: [email protected] <indo-oracle%40yahoogroups.com> [mailto:
> [email protected] <indo-oracle%40yahoogroups.com>] On
> Behalf Of Ade Wahyu
> Sent: Thursday, May 03, 2007 5:12 PM
> To: [email protected] <indo-oracle%40yahoogroups.com>
> Subject: [indo-oracle] Cara Menjumlahkan
>
> Dear Master Oracle,
> Saya memiliki data :
> A B C D E
> X 5 Rp. 5500 5 % Rp. 1375
> X 3 Rp. 7000 5 % Rp. 1050
> Y 10 Rp. 5500 5 % Rp. 2750
> Y 4 Rp. 7000 5 % Rp. 1400
>
> Keterangan :
> D adalah parameter input..yang saya tampilkan di cursor
> saya menggunakan cursor utk menampilkan hasil tsb lalu,
> hasil data E saya dapat dari E := (C*(D/100)) * B); dan saya tidak
> menyimpan
> dalam sebuah table..
>
> Keinginan saya adalah menampilkan Sub total sbb :
> A B C D E
>
> X 5 Rp. 5500 5 % Rp. 1375
>
> X 3 Rp. 7000 5 % Rp. 1050
>
> Sub Total Rp..2425
>
> Y 10 Rp. 5500 5 % Rp. 2750
>
> Y 4 Rp. 7000 5 % Rp. 1400
>
> Sub Total Rp. 4150
>
> Pertanyaan :
> Cara menghitung sub total tersebut bgmn???
>
> Thanks...
>
> Send instant messages to your online friends http://uk.messenger
> <http://uk.messenger.yahoo.com> .yahoo.com
>
> [Non-text portions of this message have been removed]
>
> [Non-text portions of this message have been removed]
>
>
>
--
Firman HM
PT. Xsis Mitra Utama
Graha BIP 7th Floor Jl. Jend. Gatot Subroto Kav.23 Jakarta 12930 -
Indonesia
Tel : +62-21-5210565 Hotline : +62-21-5210564 Fax : +62-21-5229777
[Non-text portions of this message have been removed]