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!

max with sum

hamadaezzDec 21 2016 — edited Dec 21 2016
  • - i have two select statment , first one `(  select b.id AS bnamee from branch b )`
  • and the second one ( SELECT MAX (TOTAL )  AS fs2  , b.id  as bname FROM  ( select  sum(sa.num  * pq.points ) AS TOTAL  , b.id as bname

  FROM AGENT AG , SALESFACT SA  , productsquarter PQ  , BRANCH B

    WHERE

    AG.branch_id = b.id

    AND

  pq.quarter_id = 'Q1_16'

  AND

  sa.month = 'JAN'

  AND sa.qp_id  = pq.id

  AND b.are_id = 'AP1'

  AND ag.agent_id = sa.agent_id

 

  GROUP BY b.id  , b.are_id )  , branch b group by b.id

  )b

- when i am using the inner join it gave me this ruselt

T2 5759

DT1 5759

SH2 5759

T1 5759

DT2 5759

SH1 5759

however the correct result must be

T1  5759

so any advise

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 18 2017
Added on Dec 21 2016
3 comments
997 views