select a.* from (
select
a.cd_barang,
a.s_pcs,
a.s_harga
from 
stock a
union all
select
b.cd_barang,
sum(b.pcs) as t_pcs,
sum(b.harga) as t_harga
from 
terima b
group by
b.cd_barang
union all
select
c.cd_barang,
sum(c.pcs)*( -1) as t_pcs,
sum(c.harga) *(-1) as t_harga
from jual c
group by
c.cd_barang
) a Order By a.cd_barang

--- Pada Sen, 5/10/09, [email protected] <[email protected]> menulis:


Dari: [email protected] <[email protected]>
Judul: [indo-oracle] habis union lalu di group
Kepada: [email protected]
Tanggal: Senin, 5 Oktober, 2009, 12:14 AM


  



Hello ,

mau tanya sehabis union all, hasil datanya baru di group lagi
berdasarkan cd_barang caranya bagaimana ya ?
tks

select
a.cd_barang,
a.s_pcs,
a.s_harga
from 
stock a
union all
select
b.cd_barang,
sum(b.pcs) as t_pcs,
sum(b.harga) as t_harga
from 
terima b
group by
b.cd_barang
union all
select
c.cd_barang,
sum(c.pcs)*( -1) as t_pcs,
sum(c.harga) *(-1) as t_harga
from jual c
group by
c.cd_barang


-- 
Best regards,
fansul
mailto:fan...@yahoo. co.id

____________ _________ _________ _________ _________ __
Apakah Anda Yahoo!?
Lelah menerima spam? Surat Yahoo! memiliki perlindungan terbaik terhadap spam 
http://id.mail. yahoo.com 

















      Yahoo! Mail Kini Lebih Cepat dan Lebih Bersih. Rasakan bedanya sekarang! 
http://id.mail.yahoo.com

[Non-text portions of this message have been removed]

Kirim email ke