Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Location
    India
    Posts
    40

    Unanswered: Two insert statement in one statement..help me

    Hi All

    I created one temp &Temp_Table2 with these columns
    Dt
    Del
    ST
    M
    V

    INSERT INTO &Temp_Table2
    SELECT Dt,
    del,
    st,
    'SAL',
    nvl(ROUND(SUM(SAL),0),0)
    FROM &Temp_Table1
    GROUP BY st,
    Dt,
    del;

    INSERT INTO &Temp_Table2
    SELECT Dt,
    del,
    st,
    'CRM',
    nvl(ROUND(SUM(CRM),0),0)
    FROM &Temp_Table1
    GROUP BY st,
    Dt,
    del;

    this way i am inserting values into that table
    As here the value in M , will be different
    and all the values has to store in M only and corresponding
    value has to store in V only...

    instead of 2 select statements is there any other way that i can do it in one
    statement...it should be only SQL and PL/sql .....

    Temp table should be in that format only

    Plz suggest all the ways ..

    thanks
    Suryadevara

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    You can combine like this:

    INSERT INTO &Temp_Table2
    SELECT Dt,
    del,
    st,
    'SAL',
    nvl(ROUND(SUM(SAL),0),0)
    FROM &Temp_Table1
    GROUP BY st,
    Dt,
    del
    UNION ALL
    SELECT Dt,
    del,
    st,
    'CRM',
    nvl(ROUND(SUM(CRM),0),0)
    FROM &Temp_Table1
    GROUP BY st,
    Dt,
    del;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •