Select a.id,a.amount,ccinlineview.bamt from bb a,(Select id,sum(b.amount) bamt from cc b group by id) ccinlineview where a.id = ccinlineview.id

ID         AMOUNT     BAMT

---------- ---------- ----------

        1000         1000

1 row selected.

 

-----Original Message-----
From: sultan [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 13, 2002 10:53 AM
To: Multiple recipients of list ORACLE-L
Subject: SQL Help Urgent!!!!!!!!!

Hi gurus
 
I have two tables like this
 
 
SQL> select * from bb;
 
        ID     AMOUNT         DT
---------- ---------- ------------------------------
         1       1000          10-MAY-02
 
 
 
 
SQL> select * from cc;
 
        ID     AMOUNT
---------- -------------------
         1        200
         1        300
         1        500
 
 
My query like this
=============
SQL>  select a.id,sum(a.amount),sum(b.amount)  from bb a,cc b  where
  2   a.id=b.id
  3    group by
  4    a.id;
 
        ID     SUM(A.AMOUNT)     SUM(B.AMOUNT)
        ---------- ------------- ----------------------------------------
         1          3000                     1000
 
 
**** Based on the details table rows it sum up three times the master amount ,that is why it shows 3000.
 
 
But my output should be like this
========================
 
        ID     SUM(A.AMOUNT)     SUM(B.AMOUNT)
        ---------- ------------- ----------------------------------------
         1          1000                     1000
 
 
Anybody can help me in this issue please.
 
Regards.
syed

Reply via email to