Mas Aly,
Coba dengan query sbb :
select a.data_uid,
sum(a.amount) - (select sum(b.amount) from table_2 b where
b.data_uid=a.data_uid group by b.data_uid)
from table_1 a
group by a.data_uid
Prinsipnya adalah sum terlebih dahulu dari table_1 kemudian di minus dengan sum
dari table_2 namun di dalam query table_1.
Semoga bisa membantu.
Chandra
------------------------------------------------------------------------------------------------------------------
http://orafind.com
Join Oracle Groups : PL / SQL Tips and Tricks at [EMAIL PROTECTED]
aly rmb <[EMAIL PROTECTED]> wrote: 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 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 :
>
> 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]
------------------------------------
--
-----------I.N.D.O - O.R.A.C.L.E---------------
Keluar: [EMAIL PROTECTED]
Website: http://indooracle.wordpress.com
-----------------------------------------------
Bergabung dengan Indonesia Thin Client User Groups,
Terminal Server, Citrix, New Moon Caneveral, di:
http://indo-thin.blogspot.comYahoo! Groups Links
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
[Non-text portions of this message have been removed]