Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL Help Urgent!!!!!!!!!

Re: SQL Help Urgent!!!!!!!!!

From: sultan <ssyed_at_fine.co.ae>
Date: Mon, 13 May 2002 21:48:18 -0800
Message-ID: <F001.0045FDF7.20020513214818@fatcity.com>


I got it.Thank you Gurus for your reply.

Regards
syed

> > sultan wrote:
> >
> > 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

> 
> Do the GROUP BY in an in-line view. BTW in the case you give as example,
> you just need to put B.AMOUNT in the GROUP BY clause.
> -- 
> Regards,
> 
> Stephane Faroult
> Oriole Software
> -- 
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> -- 
> Author: Stephane Faroult
>   INET: sfaroult_at_oriole.com
> 
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
> 

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: sultan
  INET: ssyed_at_fine.co.ae

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue May 14 2002 - 00:48:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US