1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Join two SELECTs without UNION

Discussion in 'SQL PL/SQL' started by Paul, Apr 4, 2014.

  1. Paul

    Paul Active Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    55
    Join two SELECTs without UNION
    For example,
    Code (Text):

    SELECT TXT,CODE,SUM(a1)
    FROM tabl1
    GROUP BY TXT,CODE;

    SELECT TXT,SUM(a1)
    FROM tabl1
    GROUP BY TXT;
     
     
  2. Paul

    Paul Active Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    55
    Code (Text):

    SELECT decode(grouping(CODE),1,'Total TXT:'||TXT,CODE) TXT,CODE,SUM(a1)
    FROM tabl1
    GROUP BY TXT,rollup(CODE);