Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

compare sums of two separate tables to each other.

mlov83May 24 2010 — edited May 25 2010
i have two tables
 table pants

id amt
1 50
1 50
1 50


table jacket

id amt
1  50
1  50
1  50

when i do a select  of say 


SELECT  a.id, b.id   SUM(a.amt),sum(b.amt) from pants a, jacket b WHERE A.ID = B.ID group by a.id, b.id 


/* i get a really awkaward result i can't understand what im doing wrong*/
i would like to get just one line with the result set


a b a.mt b.amt
1 1 150 150


but instead my amounts get duplicate like 3 or four times. like 450 and 450 ????
I have tried using DISTINCT on the sql but i have gotten no where can anyone throw me a bone here.
Thanks in advance.
This post has been answered by Sudhakar_B on May 25 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2010
Added on May 24 2010
11 comments
2,694 views