Hi, mungkin query ini bisa dicoba
SELECTa1.data_uid,ABS(a1.amount-b1.amount)FROM(SELECTSUM(a.amount)amount,data_uidFROM
GROUP
(SELECTtes1aBYdata_uid)a1,SUM(b.amount)amount,data_uidFROMtes2bGROUPBYdata_uid)b1WHEREa1.data_uid
 =b1.data_uid


----- Original Message ----
From: aly rmb <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, May 7, 2008 4:17:10 PM
Subject: Re: [indo-oracle] Compare 2 table


ini maa, hasilnya sama, ama queri-nya p'Ferry :(

Antonius Bayu <[EMAIL PROTECTED] com> wrote: Hi. mungkin query ini bisa dicoba

select a.data_uid,sum( nvl(a.amount, 0)) -sum( nvl(b.amount, 0)) 
from table1 a,table2 b
where a.data_uid = b.data_uid
group by a.data_uid

CMIIW

----- Original Message ----
From: aly rmb <[EMAIL PROTECTED] com>
To: indo-oracle@ yahoogroups. com
Sent: Wednesday, May 7, 2008 2:05:20 PM
Subject: Re: [indo-oracle] Compare 2 table

Sebelumnya, terimakasih atas responnya,
Tadi sebelum tanya, sudah sempat coba queri ini, cuma hasilnya tidak sesuai,
misal : 
table_1
data_uid amount
------------ -----------
3 5
3 14

table_2
data_uid amount
------------ -----------
3 5
dgn queri di bawah hasil amountnya = 9, sedang yg di inginkan : amount = 14

slm/Al

Ferry Setiawan <[EMAIL PROTECTED] com> wrote:
select a.data_uid,sum( nvl(a.amount, 0) - nvl(b.amount, 0))
from table1 a,table2 b
where a.data_uid = b.data_uid
group by a.data_uid

regards
Ferry

2008/5/7, aly rmb <[EMAIL PROTECTED] com>:
>
> Salam semuanya,
> TABLE_1
> DATA_UID AMOUNT
> ------------ --- ------------
> 1 4
> 1 3
> 2 20
>
> TABLE_2
> DATA_UID AMOUNT
> ------------ --- ------------ -
> 1 7
> 2 24
> Klo queri spt ini,
> select data_uid, sum(amount)
> from table_1 a
> group by data_uid
> having sum(amount) <> (select sum(amount)
> from table_2 b
> where b.data_uid = a.data_uid )
>
> hasilnya :
>
> DATA_UID AMOUNT
> ------------ --- ------------ -
> 2 20
> klo Amount yg di inginkan adalah selisih antara TABLE_1 dan TABLE_2,
> kira* querinya spt apa ya ? (amountnya = 4 bukan 20)
>
> slm/Aly
>

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

Send instant messages to your online friends http://uk.messenger .yahoo.com 

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

____________ _________ _________ _________ _________ _________ _
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile. Try it now. http://mobile. yahoo.com/ 
;_ylt=Ahu06i62sR 8HDtDypao8Wcj9tA cJ

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

Send instant messages to your online friends http://uk.messenger .yahoo.com 

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

 


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

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

Kirim email ke