title: Select query with left outer join and sum with group by
body: <p>I have 3 tables for example</p>
  
  <p><strong>Parent Table :TEST_SUMMARY</strong></p>
  
  <p><strong>Child Tables : TEST_DETAIL, TEST_DETAIL2</strong></p>
  
  <p><img src="https://i.stack.imgur.com/sEK2P.png" alt="Image Attached"></p>
  
  <p>I have data show in image, and want output result shown in image,</p>
  
  <p>I tried below 2 query, but not giving expected output</p>
  
  <pre><code>SELECT s.NAME, sum(s.AMT), sum(d.d_amt), sum(d2.d2_amt)
  FROM TEST_SUMMARY s LEFT OUTER JOIN TEST_DETAIL d
  ON s.ID = d.SUMMARY_ID 
  LEFT OUTER JOIN TEST_DETAIL2 d2
  ON s.ID =d2.SUMMARY_ID
  GROUP BY s.NAME
  ORDER BY s.NAME;
  
  select rs1.*,rs2.total1,rs3.total2
  FROM
  (select id, name,amt from TEST_SUMMARY a) RS1,
  (select SUMMARY_ID, sum(d_amt) over(partition by summary_id ) total1 from TEST_DETAIL a) RS2,
  (select SUMMARY_ID, sum(d2_amt) over(partition by summary_id ) total2 from TEST_DETAIL2 a) RS3
  where rs1.id(+)= RS2.SUMMARY_ID
  and rs1.id(+)= RS3.SUMMARY_ID;
  </code></pre>
  
  <p>Create table and insert data test Queries </p>
  
  <pre><code>CREATE TABLE TEST_SUMMARY(ID NUMBER, NAME VARCHAR2(20 BYTE),AMT  NUMBER(10,2));
  
  CREATE TABLE TEST_DETAIL (ID NUMBER, SUMMARY_ID NUMBER, NAME VARCHAR(20), D_AMT NUMBER(10,2));
  
  CREATE TABLE TEST_DETAIL2 (ID NUMBER, SUMMARY_ID NUMBER, NAME VARCHAR(20), D2_AMT NUMBER(10,2));
  
  INSERT INTO TEST_SUMMARY VALUES (1, 'NAME1', 100);
  INSERT INTO TEST_SUMMARY VALUES (4, 'NAME1', 150);
  INSERT INTO TEST_SUMMARY VALUES (6, 'NAME1', 50);
  INSERT INTO TEST_SUMMARY VALUES (2, 'NAME2', 200);
  INSERT INTO TEST_SUMMARY VALUES (3, 'NAME3', 300);
  
  INSERT INTO TEST_DETAIL VALUES (1, 1, 'NAME11', 11);
  INSERT INTO TEST_DETAIL VALUES (2, 1, 'NAME12', 12);
  
  INSERT INTO TEST_DETAIL2 VALUES (1, 1, 'NAME_2_11', 1);
  INSERT INTO TEST_DETAIL2 VALUES (2, 1, 'NAME_2_12', 1);
  </code></pre>