Help on summing data

I have below two tables:
         Table A
          col1 col2
          1     10
          1     10
          1     10
          Table b
          Col1 col2
          1    20
          Desired output:
          a.col1 sum(a.col2),sum(b.col2)
          1     30          20Please help..
Edited by: [email protected] on Apr 28, 2010 12:37 AM

Here is a try with full outer join:
SQL> WITH A AS (SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
  2             SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
  3             SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
  4             SELECT 2 col1, 40 col2 FROM DUAL UNION ALL
  5             SELECT 4 col1, 140 col2 FROM DUAL),
  6       B AS (SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
  7             SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
  8             SELECT 2 col1, 50 col2 FROM DUAL UNION ALL
  9             SELECT 2 col1, 50 col2 FROM DUAL UNION ALL
10             SELECT 3 col1, 150 col2 FROM DUAL)
11  -- End of sample data
12  SELECT   NVL(s_a.col1, s_b.col1) AS col1, sum_a, sum_b
13      FROM (SELECT   col1, SUM(col2) AS sum_a
14                FROM a
15            GROUP BY col1) s_a
16           FULL OUTER JOIN
17           (SELECT   col1, SUM(col2) AS sum_b
18                FROM b
19            GROUP BY col1) s_b ON s_a.col1 = s_b.col1
20  ORDER BY 1;
      COL1      SUM_A      SUM_B
         1         30         20
         2         40        100
         3                   150
         4        140Urs

Similar Messages

  • Using Dimension Formulas to sum data based on different criteria

    Hi all,
    I am trying to use a u201CDimension Formulau201D to perform the following calculation:
    We have an account dimension which has 2 important properties:
    1.     CRITERIUMTYPE: This property can have 3 different values: u201CWERKu201D, u201CINVu201D OR u201CLIQu201D
    2.     ACCTYPE: This property can have 2 different values: u201CEXPu201D or u201CINCu201D
    The client wants to have a report that sums data based on these 2 properties. An example will help to clarify this:
    ACCOUNTS     CRITERIUMTYPE     ACCTYPE     VALUE
    ACCOUNT A         WERK                          EXP               100 u20AC
    ACCOUNT B         WERK                          INC               150 u20AC
    ACCOUNT C         WERK                          EXP               200 u20AC
    ACCOUNT D         WERK                          INC               300 u20AC
    ACCOUNT E         INV                          EXP               50 u20AC
    ACCOUNT F         INV                          INC               100 u20AC
    ACCOUNT G         INV                          EXP               200 u20AC
    ACCOUNT H         INV                          INC               500 u20AC
    The clients wishes to see this data in the following way:
    CRITERIUMTYPE     ACCTYPE     VALUE
       WERK                         EXP              300 u20AC
                                        INC              450 u20AC
       INV                         EXP              250 u20AC
                                     INC              600 u20AC
    In order to achieve this I have created several new accounts, one for each combination e.g.: Account WERKEXP is used to sum the data on the combination CRITERIUMTYPE=WERK and ACCTYPE=EXP. I have created a dimension formula in my account dimension but this is where I am stuck. I have created the following formula to calculate the account WERKEXP:
    IIF([BUDGETPOSITIE].CURRENTMEMBER.PROPERTIES("ACCTYPE")="EXP",IIF([BUDGETPOSITIE].CURRENTMEMBER.PROPERTIES("CRITERIUMTYPE")="WERK",[BUDGETPOSITIE].CURRENTMEMBER,0),0)
    The problem with this formula is the following:
    The formula will add all amounts that meet the 2 criteria mentioned in the formula, EXP and WERK, but as soon as it finds an accounts that does not match the 2 criteria it will set the account WERKEXP back to 0. I need to know if there is a way, using dimension formulas, of adding these values together without the new account being set to 0 as soon as one of the accounts it needs to check does not meet 1 of the 2 criteria.
    We are working on SAP BPC 7.5 for NW with SP04
    All help is very much appreciated!
    Kind regards,
    Stefano

    Hi,
    You can also use ParentHn property to have different grouping of accounts within the dimension.
    So in your case rather using the member formula you can have four accounts and add them in the Parenthn property for grouping it.
    1. The Solution proposed by Nilanjan is specific for a Report/IS and Performance will be good
    2. My solution will be global something similar to MDX formula, but performance may be slightly lesser than using excel function.
    Hope this helps,
    Regards,
    G.Vijaya Kumar

  • I need help on sum

    Post Author: genesis
    CA Forum: Formula
    Hello I need help on sum
    this is my example
    W/O      Status         Datew1681     008   05/01/2007 7:00 amw1681     009   05/01/2007 8:10 amw1681     010   05/01/2007 9:00 am
    I need to sum how long to to move from step 008, 009 and 010
    W/O      Status          Datew1681     008   05/01/2007 7:00 amw1681     009   05/01/2007 8:10 am  1:10  Hourw1681     010   05/01/2007 9:00 am  0:50 minutes
    The table & field that hold date value is WO_TASK_STATUS.ENTRY_DATE

    Post Author: bryanflora
    CA Forum: Formula
    Insure you already order the data in W/O then Status.Write a formula like this:{WO_TASK_STATUS.ENTRY_DATE} - Previous({WO_TASK_STATUS.ENTRY_DATE})Because it get the field value from the previous row, so in right order is important.

  • Need help in transfering data to my new iphone4 from my old iphone3

    Hello, just received my new iphone 4, need help in transfering data from my old iphone 3 photos, emails etc. apps, thank you

    http://support.apple.com/kb/ht2109

  • Need help in oracle data recovery

    Friends ,i need help in oracle data recovery.
    I had an oracle 8i database running on windows.
    For some reason Windows operating system crashed.
    It is not booting up.
    I dont have current backups.But my database physical files are in the disk.
    Controlfile,datafiles and redo log files are there.
    Is there any way I can recover my database?
    Please help in this issue.
    regards
    Ajith

    HI citrus,
    thanks for the reply.
    I have installed database 9i on the same PC after O/S reinstallation.
    You are saying that ,I need to keep oracle root folder same as that of my old installation ,and copy control files,redo log and data files in exactly same folders as that of old database,and then start the database?
    thank you for your patience and support.
    regards.,
    Ajith

  • HT2292 Have upgraded to itunes 11.0.1.12 start itunes and it is closed, message reads I tunes closed to help protect computer, data execution prevention has closed itunes. windows Vista 32bit

    Have upgraded to itunes 11.0.1.12. Start itunes and it is closed with the message itunes closed to help protect computer data execution prevention has closed itunes. operating system is ms vista 32 bit. I have followed the procedures that I can find on the itune support site.

    You're welcome. Glad you got things sorted out.
    (No problem about not spotting the solutions ... the most common causes of this sort of message changes over time, so it's not straightforward to be able to tell when a given piece of advice still applies to the symptoms. Definitely worth posting to try to get a current heads-up on the likely contemporary causes of a particular error message.)

  • I need help proving the date tag on a photo stored in my iPhoto is from the date it was sent to my iphone/date it was imported into iphoto - and that it is NOT the date the photo was actually taken.  Please help!

    I need help proving the date tag on a photo stored in my iPhoto is from the date it was sent to my iphone/date it was imported into iphoto - and that it is NOT the date the photo was actually taken.   I recieved a photo via text on my iphone and then I synced my iphone to my macbook and now it is in iphoto.  I already know that the date on the photo per the tag that shows up on it in iphoto is NOT the date the photo was actually taken.  I need article or literature or something confirming the tag is from when it was sent to the iphone and/or when it was imported.  I greatly appreciate some assistance!

    All I am trying to do is find something on a forum board or article etc stating that the the date showing in iphoto could be the date it was imported or synced or sent to me and not the actual date taken.
    The date on the photo could be anything because you can edit the date with iPhoto or any of 100 apps, free and paid for. So, the date on the photo will prove nothing, I'm afraid.
    Regards
    TD

  • Need help in converting date format

    Hi,
    Need help in converting date format from 'DD-MON-YYYY' to 'YYYY-MM-DD' in an .rtf template as I believe xml publisher supports the date format as 'YYYY-MM-DD' only.
    Thanks,
    Raj.

    I got the same problem, anyone know how to solve this problem? I allready found some date functions on http://blogs.oracle.com/xmlpublisher/2008/09/date_functions.html . I also tried <?xdoxslt:month_name(xdoxslt:get_month(xdofx:substr(NEED_BY_DATE, 4,3)), $_XDOLOCALE), 0, 'nl-NL')?>, but then it returns a namespace error (Caused by: oracle.xdo.parser.v2.XPathException: Namespace prefix 'xdofx' used but not declared.). Anyone know how to fix this?
    Edited by: user11165753 on 7-dec-2009 23:50

  • Dump in Value-Help Component for date

    I created a Value-Help-Component for date fields. (I cannot use the standard value help, because I need the help to start in the month, the user is working on).
    I am using the Date Navigator to select a date.
    If I first change the month with an arrow of the date navigator and then select a date I get a dump in the method IF_WD_CONTEXT_ELEMENT~GET_ATTRIBUTE_REF in line
        attr_info = me->node_info->if_wd_context_node_info~get_attribute( name_only ).
    , because the element does not have a node_info.
    If I just choose a date in the preselected month (without using the arrows of the date navigator) everything is fine.
    Does anybody have an idea??
    Many thanks in advance.

    I found the "solution" to the problem myself.
    I used the method bind_structure in the component containing the date navigator.
    After I replaced it by set_static_attributes it worked without producing dumps.
    Very strange!

  • I am using pages '09. I have been trying to put together a report and I am using tables to help keep my data in line. My data is free text and would like to footnote certain data as to it origin, but footnoting is grey-out. How can I footnote on table mod

    I am using pages '09. I have been trying to put together a report and I am using tables to help keep my data in line. My data is free text and would like to footnote certain data as to it origin, but footnoting is grey-out. How can I footnote in table mode inpages '09?

    Footnotes can only be inserted in the main text area between the margins on a Word Processing document.
    Peter

  • Gurus..need help in reading data from virtual infocube

    Gurus,
    I have to read data from an virtual infocube...I am trying to use FM RSDRI_INFOPROV_READ to read data but it doesn't work..
    I am doing exactly what has been done in the demo program RSDRi_INFOPROV_READ_DEMO...
    Please help me...its really URGENT...
    Thanks
    sam

    Check out this thread....
    must be helpful
    Re: Read data from 0BWTC_C02 via ABAP

  • Need Help about Spatial Data Load - Mapviewer

    Hello everybody,
    I need an immediate help about spatial data load. I installed Oracle mapviwer quick start and try to work on it. However, I could not pass the load step. My questions are;
    1- Where can I find and download my country's data set (spatial data)
    2- With mapviwer, how can I load spatial data to my tables on database (Oracle). Those tables have sdo_geometry columns and I want to query location data, but could not load
    Regards,
    Dilek

    For Mapviewer questions, please post in the following forum:
    MapViewer
    Thanks

  • F4 help for PO date field in VA01 transaction during upgrade

    Hi All,
    We are working on upgrade project 4.6c to ECC 6.
    We came across one scenario.
    F4 help for PO date field is not coming in newer version in VA01 transaction but i checked in older version it is coming F4 help for PO date(calender).
    May i know the reason regarding this.
    Any clues
    Regards
    Jai
    Edited by: Jayanth16 on Nov 12, 2009 6:14 PM
    Edited by: Jayanth16 on Nov 12, 2009 6:22 PM

    Hi,
    User did some changes in include LSDSDF05 due to that F4 help is not coming.
    So i correct that one.
    Regards
    Jai

  • HELP needed on Date

    Hi there everyone, pls help me . i have a question as above
    "Code a Java class called Calendar which has a static variable of type Date(initialised to 1st January 2004), a static void method called tock(int days) to advance the variable by the specified number of days, and a static Date method called getDate() to return the current date.".
    What i was thinking to write is.
    public class Calendar
    Date myDate = new Date();
    myDate = java.sql.Date.valueOf("2004-01-01"); //but my fren said i could use the toString() instead
    public static void tock(int days)
         {  int i = 1;
    while i < days;
    Date = Date + 1; // i am not sure what i am doing ...i am just a beginner .pls help
    public static Date getDate()
    { return Date;
    Are my answers correct ..? how do i advance the variable (date) by the number of specified days ? the asnwer need to print out, say 4 days , u need to print 01 Jan , 02Jan , 03 Jan , 04 Jan...
    anyone please help ..

    Since your assignment is to code a class named Calendar, I doubt that you can use the java.util.Calendar class,
    which has a useful add() method in it.
    So here is another solution:
    public class Calendar
        static Date myDate = java.sql.Date.valueOf("2004-01-01");
        public static void tock(int days)
            long t = myDate.getTime(); // returns the number of milliseconds since 1970-01-01 00:00:00 GMT
            t = t + (days * 24 * 60 * 60 * 1000); // adds the appropriate number of days in milliseonds
            myDate.setTime(t);
        public static Date getDate()
            return myDate;

  • How the SPARC ANSI 3-level architecture help to achieve data independence?

    Hi guys,
    Anybody know how the SPARC ANSI 3-level architecture help to achieve data independence?
    Regard
    Ken

    Is this an Oracle-related question? I'm not sure I see the connection...
    Justin

Maybe you are looking for

  • Since upgrading to Mountain Lion LibreOffice keeps asking for Java and crashing.

    Java is needed only for Base which I don't use, so I disable Java in LibreOffice preferences, but it keeps asking if I want to enable it. In addition the preferences aren't  being remembered so sometimes LibreOffice crashes when I start to do anythin

  •  TV not showing up as a device in iTunes

    HELP! After the iTunes 8.0 update my  TV disappeared from my device list in iTunes, I checked for an update and nothing, I deleted iTunes and re-installed it and it sill didn't work! The  TV shows that my library is being synced so I'm not sure on

  • Is PS Elements 13 compatible with Windows vista?

    Completed a lengthy download of installer + program down load, + unzip of installation files.  Went through registration with product Key number, then it returned an error 001, not compatible with Vista.  I just paid for a program I cannot use?  Or d

  • Full Text Search of user properties

    Hi, How do i construct a Full TextSearch of a property in user defined type in the repository. I have a type called contacts and properties of - name, email etc I can only find ways of searching System Properties. Any hel will be well appreciated. Ch

  • Search Help hierarchy

    Hi, If for a field in a table I have the following search helps implemented: References are as under Ztab ->- Zfield --> ZdataE --> ZDomain 1. Search help at field level in table (Zfield) 2. Search help at data element (ZdataE) 3. Value Range in Doma