Grouping -  aggregation issue- Sample data included

The below data shows that this particular course A16 at a top level (set=01) equals to 60% coursework and 40% exam. At this level all the set=01's should always equal to 100%.
The complication is where a piece of Coursework and/or Exam is made up of other parts. So as we can see in the data below, the 40% coursework is made up of an Assessment paper (58%) and a Practical piece (42%). You can see the association between the 01 level, 02, 03 level through the set, subset relationship.
So record with subset 2 has two pieces associated to it.
with t as (              
select 'A16' course, '01' sett, '03' Subset, 'E' Code, 'Exam'         Descr, 40 "weight%"  from dual UNION
  select 'A16' course, '01' sett, '02' Subset, 'C' Code, 'Courswork Total' Descr, 60 "weight%"  from dual UNION
   select 'A16' course, '02' sett, ''   Subset, 'C' Code, '1. Assignement'      Descr, 58 "weight%"  from dual UNION
    select 'A16' course, '02' sett, ''   Subset, 'P' Code, '2. Practical'         Descr, 42 "weight%"  from dual UNION
     select 'A16' course, '03' sett, ''   Subset, 'E' Code, '1. Exam'             Descr, 50 "weight%"  from dual UNION
      select 'A16' course, '03' sett, ''   Subset, 'W' Code, '2. Written Piece'     Descr, 50 "weight%"  from dual)  
select * from t;This is what I had so far but this only looks at the top level which as you can see is no good as it doesnt knoe about the practical elements.
SELECT course
           ,sett
           ,NVL(SUM(CASE WHEN CODE IN ('C','F','J','L','R','Y')          THEN "weight%" end),0) AS Coursework
           ,NVL(SUM(CASE WHEN CODE IN ('E','Q')                          THEN "weight%" end),0) AS Written
           ,NVL(SUM(CASE WHEN CODE IN ('A','D','O','P','S','T','V','W')  THEN "weight%" end),0) AS Practical            
     FROM t
     where sett = 01
   GROUP BY course, sett
   ORDER BY sett; What I am trying to calculated is a total Exam%, Written%, Practical% which when all Summed equal to 100%
EXPECTED Results for the supplied data set are below:
select 'A16' course, 20 Exam,  45.2 Practical, 34.8 Coursework, 20+45.2+34.8 Total from dual;The t.Code relates to whether the piece is coursework, exam or practical. As seen below. So this is how I know what sections relate to which part.
I need to basically sieve through each level and calculate its % of the 01 level and group them into Exam, Practical and Courswork.
           CODE IN ('C','F','J','L','R','Y')          Coursework
           CODE IN ('E','Q')                          Written
           CODE IN ('A','D','O','P','S','T','V','W')  Practical  Any ideas would be much appreciated.

Thanks for that sKr.
abhi: The only issue I have with courses such as the below. This course has only has 01's so it cant roll them up, unless we use the 00 record. But if I change the code to start with 00, it will work for this one. But not the OP data i sent (This is further down this post)
START WITH T.SETT = '00'
with t as (  
--select 'A16' course, '00' sett, '01' Subset, '' Code, 'Generated'  Descr, 100 "WEIGHT"  from dual UNION -- This record is the master record.
select 'A16' course, '01' sett, '' Subset, 'O' Code, 'Presen'  Descr, 10 "WEIGHT"  from dual UNION           
select 'A16' course, '01' sett, '' Subset, 'R' Code, 'Case'    Descr, 70 "WEIGHT"  from dual UNION
select 'A16' course, '01' sett, '' Subset, 'O' Code, 'Poster'  Descr, 10 "WEIGHT"  from dual UNION
select 'A16' course, '01' sett, '' Subset, 'C' Code, 'Journel' Descr, 10 "WEIGHT"  from dual)
SELECT TT.COURSE,
             NVL(SUM(CASE WHEN TT.CODE IN ('E', 'Q') THEN "WW" END), 0)                               AS EXAM,
             NVL(SUM(CASE WHEN TT.CODE IN ('A', 'D', 'O', 'P', 'S', 'T', 'V', 'W') THEN "WW" END), 0) AS PRACTICAL,
             NVL(SUM(CASE WHEN TT.CODE IN ('C', 'F', 'J', 'L', 'R', 'Y') THEN "WW" END),     0)       AS COURSEWORK,
             NVL(SUM(WW),0) TOTAL    
    FROM (SELECT T.*, LEVEL, (CONNECT_BY_ROOT "WEIGHT") * T.WEIGHT / 100 WW
                    FROM T
                 START WITH T.SETT = '01'
                CONNECT BY SETT = PRIOR SUBSET) TT
WHERE TT.SUBSET IS NULL
GROUP BY COURSE;In the OP, the data set had master levels at 01. But there is actual one more level above that which is 00 and all courses have one. I thought I would mention it in-case it can be use to fix the above examples: OP data below with the missing 00 record.
with t as (  
select 'A16' course, '00' sett, '01' Subset, '' Code, 'Generated'         Descr, 100 "WEIGHT"  from dual UNION           
select 'A16' course, '01' sett, '03' Subset, 'E' Code, 'Exam'         Descr, 40 "WEIGHT"  from dual UNION
select 'A16' course, '01' sett, '02' Subset, 'C' Code, 'Courswork Total' Descr, 60 "WEIGHT"  from dual UNION
select 'A16' course, '02' sett, ''   Subset, 'C' Code, '1. Assignement'      Descr, 58 "WEIGHT"  from dual UNION
select 'A16' course, '02' sett, ''   Subset, 'P' Code, '2. Practical'         Descr, 42 "WEIGHT"  from dual UNION
select 'A16' course, '03' sett, ''   Subset, 'E' Code, '1. Exam'             Descr, 50 "WEIGHT"  from dual UNION
select 'A16' course, '03' sett, ''   Subset, 'W' Code, '2. Written Piece'     Descr, 50 "WEIGHT"  from dual)
SELECT TT.COURSE,
             NVL(SUM(CASE WHEN TT.CODE IN ('E', 'Q') THEN "WW" END), 0)                               AS EXAM,
             NVL(SUM(CASE WHEN TT.CODE IN ('A', 'D', 'O', 'P', 'S', 'T', 'V', 'W') THEN "WW" END), 0) AS PRACTICAL,
             NVL(SUM(CASE WHEN TT.CODE IN ('C', 'F', 'J', 'L', 'R', 'Y') THEN "WW" END),     0)       AS COURSEWORK,
             NVL(SUM(WW),0) TOTAL    
    FROM (SELECT T.*, LEVEL, (CONNECT_BY_ROOT "WEIGHT") * T.WEIGHT / 100 WW
                    FROM T
                 START WITH T.SETT = '01'
                CONNECT BY SETT = PRIOR SUBSET) TT
WHERE TT.SUBSET IS NULL
GROUP BY COURSE;
Edited by: oraCraft on Mar 12, 2012 10:16 AM

Similar Messages

  • PLEASE HELP, i'm running out of time, .......sample data included..!!

    Hi, i need some help.
    my query is:
    SELECT CANTEACH.LECTURERID, LECTURER.SURNAME, LECTURER.FORENAME, MODPART.MODPARTID, MODPART.MODPARTDESC, MODUL.MODULNAME, MODUL.MODULEVEL
    FROM CANTEACH, LECTURER, MODPART, MODUL
    WHERE CANTEACH.LECTURERID = LECTURER.LECTURERID
    AND MODPART.MODULID = CANTEACH.MODULID
    AND MODPART.MODPARTID = CANTEACH.MODPARTID
    AND MODPART.MODULID = MODUL.MODULID
    <----------------------------------------------->
    AND CANTEACH.LECTURERID = 'L'
    OR CANTEACH.LECTURERID = 'P'
    AND NOT CANTEACH.LECTURERID= ('L','P')
    <-------------------------------------------------------------->
    this was my first guess, i know it's wrong, thought i might be able to work it out from the errors, but no luck, I need help on this one.
    i'm trying to ask the db, which lecturer can teach 'only' L OR P but not both togther.
    thanks in advance
    Jd.
    Edited by: user10952460 on 15-Apr-2009 12:33
    Edited by: user10952460 on 15-Apr-2009 13:33

    SORRY ABOUT THIS, I'M NEW TO FOURMS. HERE IS WHAT YOU WANT..
    INSERT INTO MODUL VALUES ('C100','INF SYS','1');
    INSERT INTO MODUL VALUES ('C101','PROG 1','1');
    INSERT INTO MODUL VALUES ('C102','VP1','1');
    INSERT INTO MODUL VALUES ('C103','BUS COMP','1');
    INSERT INTO MODUL VALUES ('C104','PROG 2','1');
    INSERT INTO MODUL VALUES ('C200','DATABASE','2');
    INSERT INTO MODUL VALUES ('C201','SYS ANAL','2');
    INSERT INTO MODUL VALUES ('C202','VP2','2');
    INSERT INTO MODUL VALUES ('C203','HCI','2');
    INSERT INTO MODUL VALUES ('C204','OO PROG','2');
    INSERT INTO MODPART VALUES ('C100','L','LECTURE');
    INSERT INTO MODPART VALUES ('C101','L','LECTURE');
    INSERT INTO MODPART VALUES ('C102','L','LECTURE');
    INSERT INTO MODPART VALUES ('C103','L','LECTURE');
    INSERT INTO MODPART VALUES ('C103','P','PRACTICAL');
    INSERT INTO MODPART VALUES ('C104','L','LECTURE');
    INSERT INTO MODPART VALUES ('C200','L','LECTURE');
    INSERT INTO MODPART VALUES ('C201','L','LECTURE');
    INSERT INTO MODPART VALUES ('C202','L','LECTURE');
    INSERT INTO MODPART VALUES ('C202','P','PRACTICAL');
    INSERT INTO LECTURER VALUES('JBW1','WILLIAMSON','JIM','DES6');
    INSERT INTO LECTURER VALUES('PKL3','LAGER','PETER','DES6');
    INSERT INTO LECTURER VALUES('AJD2','DEWHURST','AMANDA','DES6');
    INSERT INTO LECTURER VALUES('RAC1','CAMPBELL','ROB','DES6');
    INSERT INTO LECTURER VALUES('CAB2','BRIERLY','CLAIRE','DES6');
    INSERT INTO LECTURER VALUES('PRC3','CARLISLE','PHIL','AEW3');
    INSERT INTO LECTURER VALUES('CTN3','NOON','COLIN','DES6');
    INSERT INTO LECTURER VALUES('AFI1','ISHERWOOD','ADAM','AEW3');
    INSERT INTO LECTURER VALUES('MWS4','STANHOPE','MARTIN','DES6');
    INSERT INTO LECTURER VALUES('EJK3','KEENE','EDWIN','AEW3');
    INSERT INTO canteach VALUES ('C100','L','JBW1');
    INSERT INTO canteach VALUES ('C101','L','JBW1');
    INSERT INTO canteach VALUES ('C102','L','PKL3');
    INSERT INTO canteach VALUES ('C103','L','PKL3');
    INSERT INTO canteach VALUES ('C103','P','PKL3');
    INSERT INTO canteach VALUES ('C104','L','JBW1');
    INSERT INTO canteach VALUES ('C200','L','PKL3');
    INSERT INTO canteach VALUES ('C201','L','PKL3');
    INSERT INTO canteach VALUES ('C202','L','JBW1');
    INSERT INTO canteach VALUES ('C202','P','PKL3');
    If you want the whole thing just ket me know, thanks again
    ohh and here's the table and data dic..
    CREATE TABLE LECTURER (
    LECTURERID CHAR(4),
    SURNAME CHAR(10),
    FORENAME CHAR(10),
    BOSSID     CHAR(4)
    CREATE TABLE CANTEACH (
    MODULID CHAR(4),
    MODPARTID CHAR(1),
    LECTURERID CHAR(4)
    CREATE TABLE MODUL (
    MODULID CHAR(4),
    MODULNAME CHAR(10),
    MODULEVEL CHAR(1)
    CREATE TABLE MODPART (
    MODULID CHAR(4),
    MODPARTID CHAR(1),
    MODPARTDESC CHAR(10)
    Jd.
    Edited by: user10952460 on 15-Apr-2009 12:12

  • Problems with splitting result into different rows. Group by-issue?

    Hi all!
    I have a table that looks a bit like this:
    Pallet          Status          Number          Time
    A          MoveIn          48          11:11
    A          Pick          -1          11:11
    A          Pick          -1          11:12
    A          Pick          -1          11:12
    A          MoveOut     45          11:13
    A          MoveIn          45          18:20
    A          Pick          -1          18:23
    A          Pick          -1          18:23
    A          Pick          -1          18:23
    A          Pick          -1          18:24
    A          MoveOut     41          18:25
    A          MoveIn          41          21:31
    A          Pick          -1          21:55
    .....This is logging pallets that is moved to one station and then number of boxes are picked off. (For making it more simple, I only show one pallet in above example.)
    I would like to present the result with one row for each time the pallet have been at the station, like:
    Pallet          Picked          Time
    A          3          11:11
    A          5          18:20
    A          ....          .....This means that the same pallet might be showned on several rows, as it has been to the station several times. I have tried several different "GROUP BY" but I cannot make it work.
    For example I have tried to group by hour, but this fails if a pallet is moved twice per hour or if boxes are picket at different hours (eg, first box picked 09:59, last box 10:01)
    Does anyone have a suggestion how to solve this?
    Thanks in advance and Kind regards / Anders from Sweden

    Hej, Anders,
    Can you explain what defines a group?
    It looks like you're saying that a group is a sub-set of a pallet. If we arrange all the rows for a pallet in order by time, then a new group will start every time we have a row where status='MoveIn'. That is, a group consists of a row with status='MoveIn', and all the rows immediately following it, in order by time, up to, but not including, the next row with status=-'MoveIn'. Is that right?
    If so, you can use the analytic COUNT (or SUM) function to find out how many rows with status='MoveIn' have already occurred, in order by time, like this:
    WITH     got_grp          AS
         SELECT     pallet, status, time
         ,     COUNT ( CASE
                             WHEN  status = 'MoveIn'
                       THEN  1
                         END
                    ) OVER ( PARTITION BY  pallet
                                ORDER BY          time
                        )           AS grp
         FROM    table_x
    SELECT       pallet
    ,       COUNT ( CASE
                      WHEN  status = 'Pick'
                    THEN  1
                  END
                )          AS picked
    ,       MIN (time)          AS start_time
    FROM       got_grp
    GROUP BY  pallet
    ,            grp
    ORDER BY  pallet
    ,            grp
    ;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test this.
    This assumes that the combination (pallet, time) is unique. Your sample data includes:
    Pallet          Status          Number          Time
    A          MoveIn          48          11:11
    A          Pick          -1          11:11I assume that you're just not displaying the full time, and your data is really something like:
    Pallet          Status          Number          Time
    A          MoveIn          48          23-Sep-2011 11:11:01
    A          Pick          -1          23-Sep-2011 11:11:08Otherwise, how do you know if these two rows are in te same group or not? You may need to add a tie-breaker to the analytic ORDER BY clause. For example, if you say "ORDER BY time, *status* ", then, if the two rows above really did have exactly the same time, down to the second, then the one with status='MoveIn' would be considered to be earlier than the row with status='Pick'.

  • BP 258 Sample Data Load

    Hello,
    I've configured the prereq's for the Best Practices for BPC MS 7.5 (V1.31) and am on BP 258 trying to upload the sample data provided (258_Y2010_Sales_Actual.txt).  When I run the DM package for IMPORT, it errors out with :
    Task Name : Convert Data
    Dimension  list          CATEGORY,P_CC,RPTCURRENCY,TIME,CUSTOMER,PRODUCT,SALESACCOUNT,AMOUNT
    [2010.004] Calculated member or invalid member          ACTUAL,SALESTEAM1,USD,2010.004,CUSTOMERA,PRODUCTA,SalesUnitPrice,-15000
    [2010.004] Calculated member or invalid member          ACTUAL,SALESTEAM1,USD,2010.004,CUSTOMERA,PRODUCTA,SalesQuantity,200
    [2010.004] Calculated member or invalid member          ACTUAL,SALESTEAM1,USD,2010.004,CUSTOMERA,PRODUCTA,TotalSalesRevenue,-3000000
    All I can figure from this limited info is that it does not like the conversion of the TIME dimension.  I checked my dim members and have time dim's covering the ones shown in the file (2010.004 for example).  The BP doc says nothing about maintaining the conversion file or a custom transformation file - it says to leave that empty to default to IMPORT.xls. 
    I just finished the BPC 410 course, but can't correlate what we did to this error (or I missed it). 
    Can anyone shed some light on this error? 
    thanks

    Thank you for responding.  I ran through all checks and all are OK to me. 
    1 - Optimize all green no errors
    2 - Yes I already checked this but am not 100% sure I am seeing what the system is seeing.  My dim members include the TIME items that exist in the sample data.  Only one value did not exist = members start on 2010.004 and sample data included 2010.001.  I removed those records, but it still fails.
    Here is the reject list:
    Task Name : Convert Data
    [Dimension:  TIME]
    2010.007
    2011.002
    2010.005
    2010.008
    2011.001
    2010.006
    2011.003
    2010.011
    2010.004
    2010.001
    2010.012
    2010.009
    This tells me (an inexperienced BPC person) there is a problem in conversion of the external to internal data for that dimension.  However, I have already validated that they are equal - I can't see how 2010.004 does not equate to 2010.004, unless it is comparing to the EVDESC and not the ID (2010.004 versus 2010 APR).  Am I correct on that assumption? 
    3 - Yes I've also tried changing to a new transformation file with conversion and delimiters differently mapped, but all the same result. I'm sure I am missing something trivial here!  So I do appreciate any help to figure that out. 
    Thanks again

  • CostCenter Group Aggregation problem. High Priority Issue.

    Hi Experts,
    I have very crital issue in the report, Help needed.
       I had some kind of requirement in one of the Overhead cost report, need to combine the COPA data and Costcenter(Over Head cost) data.  I have a problem with Costcenter Group aggregation on the report.
    I have Restricted 2-Keyfigures  want to derive the 3rd Keyfigure values. I given the below exmaple of the data. In my report I just want to display the KeyFigure(KF-A,B,C). I dont want to Display the Cost Center group/Costcenter Number in my report. My report ouput will be one line. But If I removed the costcenter Group I am seeing different values of the Keyfigure C, If I display the Costcenter comng with differnt Values. I am expecting the values in the column C is 1400 but it is coming like 3600.
    Please guide me how to design the Keyfigures if I want to get the value 1400 in theKeyFigre C with out Showing the Costcenter In the report.
    Cost-Center Group  R00048                         
                      Costcenter     KF-A     KF-B           KF-C
         10113     10     10          100
         10114     20     20          400
         10115     30     30          900
              60     60          1400(Insted of this its comming like 3600)
    Appreciate the response.
    Thanks,
    Venkata

    Hi,
    Check the display properties of key figure in Query Designer/Info object level.
    Set the property accordingly.
    I hope it will help.
    Thanks,
    S

  • SQL Statement -- Throws GROUP BY issue on NVL

    Hey All,
    This is pretty much my first time tackling a very complex SQL Statement but the boss is adamant about it.
    Anyways here is the information. I have 3 Tables. Table one Contains Work Order Infromation that will be listed or grouped. Table 2 and Table 3 house information that needs to be summed (Estimate hours and Actual Hours).
    So my SQL Statement looked something like this... (Its a mess)
    select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours, sum(wplabor.quantity * wplabor.laborhrs) as estimatehrs
    from maximo.workorder left outer join maximo.labtrans on labtrans.regularhrs > 0 and labtrans.refwo = workorder.wonum and labtrans.siteid = workorder.siteid or labtrans.premiumpayratetype = 'MULTIPLIER' and labtrans.refwo = workorder.wonum and labtrans.siteid = workorder.siteid left outer join maximo.wplabor on wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid
    where workorder.istask=0 and workorder.siteid='NTS' and workorder.status in ('INPRG','SCHED') and workorder.crewid in ('MAINT','DAF') and workorder.schedstart <= TO_DATE('12-13-2009','MM-DD-YYYY') and wolo3 is not null group by workorder.wonum, workorder.status, workorder.wopriority, workorder.pmnum, workorder.location, workorder.description, workorder.targstartdate, workorder.reportdate, workorder.schedstart, workorder.wolo3, workorder.wojp1
    Now the problem is that the 2nd sum (Estimate Hrs) gets HUGE numbers if there are multiple rows in Actual Hours. So I did some searching. Seems that if I used the NVL function in the SQL Statement it would fix the issue...
    select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours,
    nvl((select sum(wplabor.quantity * wplabor.laborhrs) from maximo.wplabor where wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid),0)
    from maximo.workorder left outer join maximo.labtrans on labtrans.regularhrs > 0 and labtrans.refwo = workorder.wonum and
    labtrans.siteid = workorder.siteid or labtrans.premiumpayratetype = 'MULTIPLIER' and labtrans.refwo = workorder.wonum and
    labtrans.siteid = workorder.siteid
    where workorder.istask=0 and workorder.siteid='NTS' and workorder.status in ('INPRG','SCHED') and
    workorder.crewid in ('MAINT','DAF') and workorder.schedstart <= TO_DATE('12-13-2009','MM-DD-YYYY') and wolo3 is not null
    group by workorder.wonum, workorder.status, workorder.wopriority, workorder.pmnum, workorder.location, workorder.description, workorder.targstartdate, workorder.reportdate, workorder.schedstart, workorder.wolo3, workorder.wojp1
    However If get the error not a GROUP BY expression.
    I really need this to work. How can I get the NVL to work with out having to define a Group for it. The problem is that it is a "alias column" and you cannot Group by those fields. Frustation sets in... UGH!
    Thanks in Advance, Ben.

    Hi, Ben,
    Wlecome to the forum!
    user12273726 wrote:
    So my SQL Statement looked something like this... (Its a mess)You're right. Fix that first.
    Put each SELECT item, each condition, and each GROUP BY expression on a separate line. Indent to show here the clauses (SELECT, FROM, WHERE) are.
    For example:
    SELECT    workorder.wolo3
    ,       workorder.wojp1
    ,       workorder.wonum
    ,       workorder.description
    ,       workorder.location
    ,       workorder.status
    ,       workorder.wopriority
    ,       workorder.targstartdate
    ,       workorder.reportdate
    ,       workorder.pmnum
    ,       workorder.schedstart
    ,       SUM (labtrans.regularhrs + labtrans.premiumpayhours)     AS actualhours
    ,       SUM (wplabor.quantity * wplabor.laborhrs)          AS estimatehrs
    FROM                  maximo.workorder
    LEFT OUTER JOIN   maximo.labtrans     ON      labtrans.regularhrs         > 0
                                       AND     labtrans.refwo              = workorder.wonum
                             AND     labtrans.siteid              = workorder.siteid
                             OR     labtrans.premiumpayratetype = 'MULTIPLIER'     -- WARNING!  Don't mix AND and OR
                             AND     labtrans.refwo              = workorder.wonum
                             AND     labtrans.siteid              = workorder.siteid
    LEFT OUTER JOIN   maximo.wplabor     ON     wplabor.wonum              = workorder.wonum
                                       AND     wplabor.siteid              = workorder.siteid
    WHERE     workorder.istask      = 0
    AND       workorder.siteid       = 'NTS'
    AND       workorder.status       IN ('INPRG','SCHED')
    AND       workorder.crewid       IN ('MAINT','DAF')
    AND       workorder.schedstart   <= TO_DATE ('12-13-2009','MM-DD-YYYY')
    AND       wolo3                       IS NOT NULL
    GROUP BY  workorder.wonum
    ,            workorder.status
    ,       workorder.wopriority
    ,       workorder.pmnum
    ,       workorder.location
    ,       workorder.description
    ,       workorder.targstartdate
    ,       workorder.reportdate
    ,       workorder.schedstart
    ,       workorder.wolo3
    ,       workorder.wojp1
    ;When you post formatted text on this site, type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    Now the problem is that the 2nd sum (Estimate Hrs) gets HUGE numbers if there are multiple rows in Actual Hours. Huge numbers are not necessarily wrong. Do yo mean the numbers computed by your query are much bigger than they are supposed to be?
    So I did some searching. Seems that if I used the NVL function in the SQL Statement it would fix the issue...
    select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours,
    nvl((select sum(wplabor.quantity * wplabor.laborhrs) from maximo.wplabor where wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid),0)
    ...It looks like you have a Chasm Trap, where you have multiple, independent one-to-many relationships on the same table, and the solution to aggregate them in separate queruies.
    It looks like you're trying to aggregate wplabor in scalar sub-queries, which makes the GROUP BY more complicated (as you discovered), and is also very inefficient.
    It would be easier to code and more efficient to run if you aggregated wplabor in a sub-query, and then joined to this sub-query (and not the actual wplabor table) in your main query.
    If you'd like help, post a little sample data (CREATE TABLE and INSERT statements) for all three tables, and the results you want from that data.
    Simplify as much as possible. Instead of GROUPing BY 11 columns, just GROUP BY, say, 3 columns: the 2 involved in the join condidiotns, and one more. Once you understand how to do this, adding the other expressions will be trivial.
    You can also simplify by ignoring, for now, the WHERE clause, and, therefore, the columns involved in the WHERE clause. It looks like that has nothing to do with the problem. Again, adding the conditions later will be trivial.

  • Sample data for healthcare, education or social services in United States

    Hello All,
    I need to download some sample data for my research on tableau software. Can you please provide me some links where can I download the sample data related to healthcare, education or social service in united states?
    Thank you,
    Anish
    Anish Tuladhar - Do not forget to mark as answer, only if helpful.:)

    Unfortunately your post is off topic as it's not specific to SQL Server Samples and Community Projects.  
    This is a standard response I’ve written in advance to help the many people who post their question in this forum in error, but please don’t ignore it.  The links I provide below will help you determine the right forum to ask your question in.
    For technical issues with Microsoft products that you would run into as an end user, please visit the Microsoft Answers forum ( http://answers.microsoft.com ) which has sections for Windows, Hotmail,
    Office, IE, and other products.
    For Technical issues with Microsoft products that you might have as an IT professional (like technical installation issues, or other IT issues), please head to the TechNet Discussion forums at http://social.technet.microsoft.com/forums/en-us, and
    search for your product name.
    For issues with products you might have as a Developer (like how to talk to APIs, what version of software do what, or other developer issues), please head to the MSDN discussion forums at http://social.msdn.microsoft.com/forums/en-us, and
    search for your product or issue.
    If you’re asking a question particularly about one of the Microsoft Dynamics products, a great place to start is here: http://community.dynamics.com/
    If you think your issue is related to SQL Server Samples and Community Projects and I've flagged it as Off-topic, I apologise.  Please repost your question and include as much detail as possible about your problem so that someone can assist you further. 
    If you really have no idea where to post your question please visit the Where is the forum for…? forum http://social.msdn.microsoft.com/forums/en-us/whatforum/
    When you see answers and helpful posts, please click Vote As Helpful,
    Propose As Answer, and/or Mark As Answer
    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCSA, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID:
    Microsoft Transcript

  • SQL Group by issues

    Hi All
    I am new to SQL .
    There are two tables EMP and DEPT . The common column betwee these two is DEPT_NO
    Al I am trying to do is display the department name , number of employees and the department's average salary of the employees.
    Below id my query . I am not able to complete the query due to the issues that group by clause poses .
    Could some one please help ?
    SELECT DEPT.DEPT_NAME , SUM(EMP.EMP_NO) , AVG(EMP.SAL)
    FROM EMP , DEPT
    WHERE EMP.DEPT_NO = DEPT.DEPT_NO
    GROUP BY DEPT.DEPT_NAME
    Thanks
    Guna

    user9967723 wrote:
    I want to display the employee name, department number, and all the employees that work in the same department .This seems very different from your original request.
    Also please let me know where i can find a 'attachment link in this page' to attach the table snap shot. You cannot attach anything in this forum. Creating a text version would be the most helpful as some external sites that host images are blocked for some of the users here.
    It is always helpful to provide the following:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
    Also see the third post in this thread:
    {thread:id=2174552}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Aggregation issue for report with bw structure

    Hi,
    I am facing aggregation issue while grouping reports in webi.
    We have a BW query with 16 values, which we bring to bw as structure. Out of 16, 8 are percentage values (agg. type should be average).
    If we bring the data at site level, data is comming properly. But if we use same query and try sum/grouping( on region level), then percentage is getting added.
    Since it's a dashboard report with lots of filters, we cannot go for seperate query at each level(site, region, zone).
    How we can resolve this.. please give me suggestion.
    Regards
    Baby

    Hi,
    Since we were using structure, it was not possible to produce the required result in BO.
    We change structure to keyfigures and bring all of them in to BO. All the column formulas are now in BO side.
    Now it is working fine.
    Regards
    Baby
    Edited by: Baby on May 10, 2010 11:39 AM

  • Start Routine to Populate Account Group Field from Master data of 0Customer

    Hello Friends. Please help me edit this ABAP code to make it work. I am putting this code in start routine in between two DSO. where I am using the
    Start Routine to Populate Account Group Field from Master data of 0Customer. I do not want to use read from master data functionality since that field 0customer is not there in dso but similar field 0debitor is there. so i want to put this code
    during the load from source DSO to Target DSO.
    Error Explicit length specifications are necessary with types C, P, X, N und
    DATA: L_S_DP_LINE TYPE DATA_PACKAGE_sTRUCTURE.
        types: begin of comp,
         CUSTOMER       type  /BI0/OICUSTOMER,
         ACCNT_GRP          type /BI0/OIACCNT_GRP,
       end of comp.
        DATA: l_S_comp type comp.
        DATA: L_th_COMP TYPE HASHED TABLE OF COMP WITH UNIQUE KEY customer INITIAL SIZE 0.
    IF  L_th_COMP[] IS INITIAL.
    SELECT CUSTOMER ACCNT_GRP FROM /BI0/PCUSTOMER APPENDING CORRESPONDING FIELDS OF TABLE L_th_COMP.
    ENDIF.
    LOOP AT SOURCE_PACKAGE INTO L_S_DP_LINE.
    READ TABLE L_TH_COMP INTO L_S_COMP WITH TABLE KEY CUSTOMER = L_s_DP_LINE-CUSTOMER
    IF SY-SUBRC = 0.
    L_S_DP_LINE-/BIC/ACCNT_GRP = L_S_COMP-/BIC/ACCNT_GRP.
    MODIFY SOURCE_PACKAGE FROM L_S_DP_LINE.
    ENDIF.
    ENDLOOP.
    soniya kapoor
    Message was edited by:
            soniya kapoor

    Hello Wond Thanks for Good Answer and good option, But Client does not like this option and does not like Nav Attribute so he does not want to turn on any Nav Attribute, In general also We hav requirement to read a third table while uploading 1 dso table to 2 dso table,
    so  Please help me edit this ABAP code to make it work. I am putting this code in start routine in between two DSO. where I am using the
    Start Routine to Populate Account Group Field from Master data of 0Customer.
    No syntax Error But during the load it is updating the source table and not the target table. how to define now target table.
    ***SOURCE DSO Table
    types: begin of typ_tgl1.
        include type /BIC/AZDAFIAR000.
        types: end of typ_tgl1.
        types: begin of comp,
         CUSTOMER       type  /BI0/OICUSTOMER,
         ACCNT_GRP          type /BI0/OIACCNT_GRP,
       end of comp.
    DATA: L_th_COMP TYPE HASHED TABLE OF COMP WITH UNIQUE KEY customer
    INITIAL SIZE 0.
      data: wa_itab type COMP.
        data: wa_zdtg type typ_tgl1.
    IF  L_th_COMP[] IS INITIAL.
    ***Master Data Table
    SELECT CUSTOMER ACCNT_GRP FROM /BI0/PCUSTOMER APPENDING CORRESPONDING
    FIELDS OF TABLE L_th_COMP.
    sort L_th_COMP by CUSTOMER.
    ENDIF.
    LOOP AT L_th_COMP into wa_itab.
    select * from /BIC/AZDAFIAR000 into wa_zdtg
                        where DEBITOR  eq wa_itab-CUSTOMER.  *** SOURCE DSO Table
    IF SY-SUBRC = 0.
    wa_zdtg-ACCNT_GRP = wa_itab-ACCNT_GRP.
    MODIFY /BIC/AZDAFIAR000 from wa_zdtg. *** modify SOURCE DSO Table
    ENDIF.
      endselect.
        endloop.
    soniya kapoor

  • Issue in Data from DSO to DSO Target with different Key

    Hello All,
    I am having Issue in Data from DSO to DSO Target with different Key
    Source DSO has Employee + Wage + Post numner as key and Target has Employee + Wage Type as key.
    DSO semantic grouping works like Group By clause in sql, is my understanding right ?
    Also if someone can explain this with a small example, it would be great.
    Many Thanks
    Krishna

    Dear, as explained earlier your issue has nothing to do with semantic grouping .
    Semantic grouping is only usefull when you have written a routine in the transformation for calculations and in error handling .
    Please go through this blog which explains very clearly the use of semantic grouping .
    http://scn.sap.com/community/data-warehousing/netweaver-bw/blog/2013/06/16/semantic-groups-in-dtp
    Now coming to your above question
    DSO 1
    Employee WageTyp Amount
    100          aa          200
    200          aa          200
    100          bb          400
    100          cc          300
    If we have semantic group as Employee .   If we have Employee as key of the target DSO and update type as summation .
    then target DSO will have
    Emp                Amount
    100                 700
    200                 200
    In this case Wage type will be the last record arriving from the data package . If the record 100  cc  300 is arrivng last then wage type will be cc .
    2) Case 2
    DSO 1
    Employee WageTyp Amount
    100          aa          200
    200          aa          200
    100          bb          400
    100          aa          300
    if we do Semantic grouping with Emp and Wage Type   If we have Employee and wage type as key of the target DSO and update type as summation .
    then target DSO will have
    Emp     Wage      Amount
    100          aa          500
    200          aa          200
    100          bb          400
    Hope this helps .

  • For this sample data how to fulfill my requirement ?

    For this sample data how to fulfill my requirement ?
    with temp as
    select 'MON' WEEKDAY,'9-10' TIMING,'I' CLASS FROM DUAL UNION
    select 'MON' WEEKDAY,'9-10' TIMING,'II' CLASS FROM DUAL UNION
    select 'MON' WEEKDAY,'9-10' TIMING,'III' CLASS FROM DUAL UNION
    select 'MON' WEEKDAY,'10-11' TIMING,'I' CLASS FROM DUAL UNION
    select 'MON' WEEKDAY,'10-11' TIMING,'II' CLASS FROM DUAL UNION
    select 'TUE' WEEKDAY,'9-10' TIMING,'I' CLASS FROM DUAL UNION
    select 'TUE' WEEKDAY,'9-10' TIMING,'II' CLASS FROM DUAL
    select ?? (what will be the query ??)
    How can i get output data in this way :
    WEEKDAY TIMING CLASS
    MON 9-10 I,II,III
    MON 10-11 I,II
    TUE 9-10 I,II

    If in 11g, you can use LISTAGG
    with temp as
    select 'MON' WEEKDAY,'9-10' TIMING,'I' CLASS FROM DUAL UNION
    select 'MON' WEEKDAY,'9-10' TIMING,'II' CLASS FROM DUAL UNION
    select 'MON' WEEKDAY,'9-10' TIMING,'III' CLASS FROM DUAL UNION
    select 'MON' WEEKDAY,'10-11' TIMING,'I' CLASS FROM DUAL UNION
    select 'MON' WEEKDAY,'10-11' TIMING,'II' CLASS FROM DUAL UNION
    select 'TUE' WEEKDAY,'9-10' TIMING,'I' CLASS FROM DUAL UNION
    select 'TUE' WEEKDAY,'9-10' TIMING,'II' CLASS FROM DUAL
    select
    WEEKDAY,
    TIMING,
    LISTAGG(CLASS,',') WITHIN GROUP (order by 1) as class_aggregate
    from temp
    GROUP by WEEKDAY,TIMING;
    WEEKDAY       TIMING     CLASS_AGGREGATE
    MON           9-10       I,II,III
    MON           10-11      I,II
    TUE           9-10       I,IIOther techniques for different versions are also mentioned here :
    http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php#listagg

  • Need help in framing an SQL query - Sample data and output required is mentioned.

    Sample data :
    ID Region State
    1 a A1
    2 b A1
    3 c B1
    4 d B1
    Result should be :
    State Region1 Region2
    A1 a b
    B1 c d

    create table #t (id int, region char(1),state char(2))
    insert into #t values (1,'a','a1'),(2,'b','a1'),(3,'c','b1'),(4,'d','b1')
    select state,
     max(case when region in ('a','c') then region end) region1,
      max(case when region in ('b','d') then region end) region2
     from #t
     group by state
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • BPC 5 - Best practices - Sample data file for Legal Consolidation

    Hi,
    we are following the steps indicated in the SAP BPC Business Practice: http://help.sap.com/bp_bpcv151/html/bpc.htm
    A Legal Consolidation prerequisit is to have the sample data file that we do not have: "Consolidation Finance Data.xls"
    Does anybody have this file or know where to find it?
    Thanks for your time!
    Regards,
    Santiago

    Hi,
    From [https://websmp230.sap-ag.de/sap/bc/bsp/spn/download_basket/download.htm?objid=012002523100012218702007E&action=DL_DIRECT] this address you can obtain .zip file for Best Practice including all scenarios and csv files under misc directory used in these scenarios.
    Consolidation Finance Data.txt is in there also..
    Regards,
    ergin ozturk

  • EPM 11.1.2.2: Load sample data

    I have installed EPM 11.1.2.2 and now I'm trying to load the sample data. I could use help locating instructions that will help with this. While earlier versions of epm documentation seemed to have instructions for loading the sample data, I have yet to find it for 11.1.2.2. Perhaps the earlier versions' steps are supposed to work on this version as well. So I read it. It says to initialize the app then in EAS right click on a consol icon where yuo have the option to load data. Unfortunately, I am using EPMA and I saw no option to initialize when I created the app. In addition, EAS doesnt have the console icon and right clicking on the application doesnt do anything. In short, prior documentation hasnt helped so far. I did find the documentation for EPM 11.1.2.2 but I have yet to locate within it the the instructions for loading the sample application and data. Does anyone have any suggestions?

    I considered your comment about the app already existing but if this were true, I think the database would exist in EAS but it doesn't.
    I've also deleted all applications, even re-installed the essbase components including the database so it would all be fresh, and then tried to create a new one but still no initialization option is available. At this point, I'm assuming there is something wrong with my installation. Any suggestion on how to proceed would be appreciated.
    I've noticed that I dont have the create classic application option in my menu, only the transform from classic to epma option. I also can't navigate to http://<machinename>:8300/HyperionPlanning/AppWizard.jsp. When I noticed these things, I did as John suggested in another post and reselected the web server. This didnt make a difference so I redeployed apps AND selected the web server. Still not seeing it in the menu.
    Edited by: dirkp:) on Apr 8, 2013 5:45 PM

Maybe you are looking for

  • Firefox for android doesn't load all my passwords and corrupts bookmarks

    Firefox for Android doesn't load all my passwords on my tablet (Lenovo). Also, syncing corrupts my bookmarks on my desktop and laptop by inserting bookmarks which I have deleted days ago.. It syncs through all three devices and I know that it syncs b

  • Opening postcript (.ps) file in Illustrator CS5

    Dear all, I am trying to open a postcript file (.ps) in Illustrator, and my problem is that I can access only the first page of the postcript file. I would like to see all following pages as well. The .ps file is generated by a program called Psimpol

  • Make Album List view default for playlists

    I have my library broken up with playlists for each artist and I like to view the contents of each playlist in Album List view. iTunes remembers when you switch to this view, but after upgrading to iTunes 10 all playlists are back to list view, and i

  • Incorrect process dependencies

    Hi, when I just wanted to remove an application, the workbench warned me that there is one application that has dependencies on it. Because I knew there shouldn't be any, I searched through the processes but found nothing. When I looked at the proces

  • How do I limit length of a dropdown menu?

    I have a drop down menu that represents a field in my database table that is several hunfred characters long. How could I limit the size of the text box on my JSP page so that it doesn't represent the entire length of the string? Either cutting it of