Priority query

hi
i have two tables like forderung and anspourch
having of columns
fordnr, glaeubigernr, fordergnr, extfordnr, erledigtmm
8967 11 0 23/245/60 0
8968 11 0 24/245/60 0
8969 11 0 45/98/700 1
8970 11 0 23/56/71 1
the second table is like
fordnr, glaeubigernr, fordergnr
8968 11 0
8969 11 0
8970 11 0
i want to compare the two tables based on the key columns(fordnr, glaeubigernr, fordergnr)
and also the flag erledigtmm (that is present in the first table)
1)
if the key columns(fordnr, glaeubigernr, fordergnr) not present in the second table and the flag is '0' (i want to select that record first) ---------first priority--if the records are more than one select latest one
2) if the key columns(fordnr, glaeubigernr, fordergnr) present in the second table and the flag is '0' (i want to select that record second) ---------second priority---if the records are more than one select latest one
3) if the key columns(fordnr, glaeubigernr, fordergnr) not present in the second table and the flag is '1' (i want to select that record third) ---------third priority---if the records are more than one select latest one
4)if the key columns(fordnr, glaeubigernr, fordergnr) present in the second table and the flag is '1' (i want to select that record fourth) ---------4th priority---if the records are more than one select latest one
is there any way can i get the data like that (priority wise)
please adjust columns data in the below of the columns
help me in this regard
regards
sridhar

Possibly not the most efficient way of doing it, but it ought to work in principle - you may need to tune it to suit. Incidentally, I had to correct your test data as it didn't prove the fourth case.
Cheers, APC
SQL> SELECT x.pri, decode(x.pri, 3, 0, f.fordnr) AS fordnr
  2              , decode(x.pri, 3, 0, f.glaeubigernr) AS glaeubigernr
  3              , decode(x.pri, 3, 0, f.fordergnr) AS fordergnr
  4              , decode(x.pri, 3, '0', MAX(f.extfordnr)) AS extfordnr
  5  FROM   first_table f
  6         , ( SELECT * FROM (
  7              ( SELECT 1 AS pri, f.fordnr, f.glaeubigernr, f.fordergnr
  8                FROM   first_table f
  9                WHERE  f.erledigtmm =0
10                MINUS
11                SELECT 1, s.fordnr, s.glaeubigernr, s.fordergnr
12                FROM   second_table s )
13              UNION ALL
14              ( SELECT 2 AS pri, f.fordnr, f.glaeubigernr, f.fordergnr
15                FROM   first_table f
16                WHERE  f.erledigtmm =0
17                INTERSECT
18                SELECT 2, s.fordnr, s.glaeubigernr, s.fordergnr
19                FROM   second_table s )
20              UNION ALL
21              ( SELECT 3 AS pri, f.fordnr, f.glaeubigernr, f.fordergnr
22                FROM   first_table f
23                WHERE  f.erledigtmm =1
24                INTERSECT
25                SELECT 3, s.fordnr, s.glaeubigernr, s.fordergnr
26                FROM   second_table s )
27              UNION ALL
28              ( SELECT 4 AS pri, f.fordnr, f.glaeubigernr, f.fordergnr
29                FROM   first_table f
30                WHERE  f.erledigtmm =1
31                MINUS
32                SELECT 4, s.fordnr, s.glaeubigernr, s.fordergnr
33                FROM   second_table s )
34               ) ) x
35  WHERE   f.fordnr = x.fordnr
36  AND     f.glaeubigernr = x.glaeubigernr
37  AND     f.fordergnr = x.fordergnr
38  GROUP   BY x.pri, f.fordnr, f.glaeubigernr, f.fordergnr
39  ORDER   BY x.pri, f.fordnr, f.glaeubigernr, f.fordergnr
40  /
       PRI     FORDNR GLAEUBIGERNR  FORDERGNR EXTFORDNR
         1       8967           11          0 23/245/60
         2       8968           11          0 24/245/60
         3          0            0          0 0
         4       8970           11          1 23/56/71
SQL>
SQL>

Similar Messages

  • Full export dump to import schema

    Hi,
    I have an exp dump(datapump) of database, the command use for this:
    +/******* directory=expdump DUMPFILE=HYRT.dmp logfile=HYRT_exp.log FULL=y+*
    Now, I have imported the dump with the below command:
    T24OWNER/******** directory=dor dumpfile=HYRT.dmp logfile=DGFRdmp.impdp.log REMAP_SCHEMA=USER:OWNER REMAP_TABLESPACE=DATAL:BDATA,INDEL:INDEX*
    I have got several errors.
    Is this errors occured because of the import command where I used imported a schema alone?
    If I use full =y parfile in the import command, will these errors can be avoided.
    Thanks in advance,
    nonuday
    Edited by: Nonuday on Apr 29, 2012 10:56 PM
    Edited by: Nonuday on Apr 29, 2012 10:57 PM

    Hi Vishwanath,
    The import got completed.
    I have got sum of 16164 errors and I have posted each of its kind below.
    1
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    9
    bf d6
    0cfc6e4Sm6mfaMYwsbW2JygBepcwg/BKmJ4VZy/pO06UXsVUMejsissTcGWYR4qeK4TPqfDK
    q7UPH+SmKP6nW9zmxMZnuK1VDzM0Iv9O4E4SvvsnHWn+EPF9hR+oBFe3fEro6RQ5R5Ejd1nr
    e+fAK010dExf76gg/c6ZB3YxGPHDOqkGI4lV6HNsd57gKLwTd0bxan5UwJriIpt7Vjc=
    Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/FUNCTION
    ORA-31685: Object type FUNCTION:"SYSTEM"."WM$_CHECK_INSTALL" failed due to insufficient privileges. Failing sql is:
    CREATE FUNCTION "SYSTEM"."WM$_CHECK_INSTALL" return boolean is begin return false ; end;
    Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/PROCEDURE
    ORA-31685: Object type PROCEDURE:"OUTLN"."ORA$GRANT_SYS_SELECT" failed due to insufficient privileges. Failing sql is:
    CREATE PROCEDURE "OUTLN"."ORA$GRANT_SYS_SELECT" as
    begin
    EXECUTE IMMEDIATE 'GRANT SELECT ON OUTLN.OL$ TO SELECT_CATALOG_ROLE';
    EXECUTE IMMEDIATE 'GRANT SELECT ON OUTLN.OL$HINTS TO SELECT_CATALOG_ROLE';
    EXECUTE IMMEDIATE 'GRANT SELECT ON OUTLN.OL$NODES TO SELECT_CATALOG_ROLE';
    end;
    ORA-31685: Object type PROCEDURE:"SYSTEM"."ORA$_SYS_REP_AUTH" failed due to insufficient privileges. Failing sql is:
    CREATE PROCEDURE "SYSTEM"."ORA$_SYS_REP_AUTH" as
    begin
    EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.repcat$_repschema TO SYS ' ||
    'WITH GRANT OPTION';
    EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.repcat$_repprop TO SYS ' ||
    'WITH GRANT OPTION';
    EXECUTE IMMEDIATE 'GRANT SELECT ON SYSTEM.def$_aqcall TO SYS ' ||
    'WITH GRANT OPTION';
    EXECUTE
    Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/ALTER_FUNCTION
    ORA-31685: Object type ALTER_FUNCTION:"SYSTEM"."WM$_CHECK_INSTALL" failed due to insufficient privileges. Failing sql is:
    ALTER FUNCTION "SYSTEM"."WM$_CHECK_INSTALL" COMPILE PLSQL_OPTIMIZE_LEVEL= 2 PLSQL_CODE_TYPE= INTERPRETED PLSQL_DEBUG= FALSE REUSE SETTINGS TIMESTAMP '2010-11-01 16:05:09'
    Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/ALTER_PROCEDURE
    ORA-31685: Object type ALTER_PROCEDURE:"OUTLN"."ORA$GRANT_SYS_SELECT" failed due to insufficient privileges. Failing sql is:
    ALTER PROCEDURE "OUTLN"."ORA$GRANT_SYS_SELECT" COMPILE PLSQL_OPTIMIZE_LEVEL= 2 PLSQL_CODE_TYPE= INTERPRETED PLSQL_DEBUG= FALSE REUSE SETTINGS TIMESTAMP '2010-11-01 16:05:09'
    ORA-31685: Object type ALTER_PROCEDURE:"SYSTEM"."ORA$_SYS_REP_AUTH" failed due to insufficient privileges. Failing sql is:
    ALTER PROCEDURE "SYSTEM"."ORA$_SYS_REP_AUTH" COMPILE PLSQL_OPTIMIZE_LEVEL= 2 PLSQL_CODE_TYPE= INTERPRETED PLSQL_DEBUG= FALSE REUSE SETTINGS TIMESTAMP '2010-11-01 16:05:09'
    Processing object type DATABASE_EXPORT/SCHEMA/VIEW/VIEW
    ORA-31685: Object type VIEW:"SYSTEM"."MVIEW_WORKLOAD" failed due to insufficient privileges. Failing sql is:
    CREATE FORCE VIEW "SYSTEM"."MVIEW_WORKLOAD" ("WORKLOADID", "IMPORT_TIME", "QUERYID", "APPLICATION", "CARDINALITY", "RESULTSIZE", "LASTUSE", "FREQUENCY", "OWNER", "PRIORITY", "QUERY", "RESPONSETIME") AS select
    a.collectionid# as workloadid,
    a.collecttime as import_time,
    a.queryid# as queryid,
    a.application,
    a.cardinality,
    a.resultsize,
    a.qdate as lastuse,
    a.frequency,
    a.uname as o
    Processing object type DATABASE_EXPORT/SCHEMA/VIEW/GRANT/OWNER_GRANT/OBJECT_GRANT
    ORA-39112: Dependent object type OBJECT_GRANT:"SYSTEM" skipped, base object type VIEW:"SYSTEM"."MVIEW_WORKLOAD" creation failed
    Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA
    Processing object type DATABASE_EXPORT/SCHEMA/PASSWORD_HISTORY
    ORA-39083: Object type PASSWORD_HISTORY failed to create with error:
    ORA-06550: line 1, column 33:
    PLS-00201: identifier 'SYS.DBMS_PSWMG_IMPORT' must be declared
    ORA-06550: line 1, column 10:
    PL/SQL: Item ignored
    These are the errors in the log..
    I have done import from many client export dump before but they are schema level export only.
    This one is full database export where I have imported only the schema from the full exp dump. Is this the reason why am getting so many errors or anything else can you throw some light.
    Thanks in advance.
    nonuday
    Edited by: Nonuday on Apr 29, 2012 11:03 PM

  • Question on SPListItemCollection and SPListItem ContainsField

    I am retrieving items from a SharePoint List using CAML query . I specify
    ViewFields for SPQuery. I get the Items in a SPListItemCollection called "items".
    SPListItemCollection items = myList.GetItems(query);
    My problem is :
    When I try to find a field which I have not specified in the ViewFields property.
    If I do : items.Fields.ContainsField("Field not specified in viewfields") ---- Returns
    FALSE
    But if I do :
    foreach(SPListItem item in items)
    item.Fields.ContainsField("Field not specified in viewfields")   ----- Returns
    TRUE
    Is this normal? How can i ensure that only the Fields which I have selected are present in SPLIstItem ? Any help would be appreciated.

    Hi
    Refer this link
    Hi,
    Greetings.
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewfields.aspx
    you should use 
    query.ViewFields = string.Concat(
    "<FieldRef Name='AssignedTo' />",
    "<FieldRef Name='LinkTitle' />",
    "<FieldRef Name='DueDate' />",
    "<FieldRef Name='Priority' />");
    query.ViewFieldsOnly = true; // Fetch only the data that we need.
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Threading, commits, shared connection

    Have an applet with 2 threads sharing a connection, one is high
    priority thread(T1), responds to user events, other is low
    priority query thread (T2) that populates a display. Here is
    sequence of events that causes problem (d1 and d2 are 2 separate
    db tables):
    Event 1 occurs,
    T1 does the following:
    select from d1 where account = 5 for update
    update d1 set owner = me
    commit
    send message to T2 to query for more details and display
    T2 does the following:
    select from d2 where account = 5
    process records from result set, write to display
    wait for next message from T1
    THEN, very soon after event 1 occurs, event 2 occurs,
    T1 does the following:
    select from d1 where account = 22 for update
    update d2 set owner = me
    commit
    update d1 set owner = noone where account = 5
    commit
    Problem is this: the final commit hangs. And when I query the
    db outside the applet, the d1 record associated with account 5 is
    indeed locked (sqlplus hangs too on select for update!). It
    looks like the original commit did not release the d1 record.
    Possibilities:
    1. Commit messes up other query statements on same connection.
    2. Other query statements on same connection mess up commit.
    3. Something else.
    I am not using auto commit.
    Any ideas?
    null

    I'm not 100% sure what you mean, but I do know posting the same question within a few hours of each other is going to make people not want to respond.
    - Anyhow, if you're saying a computer is connected to your files that you don't want you can simply unshare any files. (System Preferences>Sharing>uncheck "File Sharing")
    If there is simply another computer listed under teh "Shared" section of finder, that isn't a big deal. They cannot access anything without you having shared the files, and vice versa. You may be able to click on that computer and look at their shared files, but odds are it'll come up "connection failed".
    Is this at your home network? The office? A public wifi spot?
    If it's your home network that means someone is connected to your wireless network. You should start by setting a password to access your wireless router. That is done differently depending on who manufactures your router. Consult their manual for advice there.
    If you're on a public WiFi other computers will pop up, there really isn't anything you can do to "remove" them per-se. But I can assure you they cannot access anything on your computer unless you have shared the files under your "shared folder" (see the first point i made)
    If you're at work/office/school it's the same deal. I'm looking at "shared" in Finder and there are 8-12 computers, none of which I know who they are. I cannot connect to any of them, if i try to it just says "Connection Failed". I'm not the most techy guy, but i believe you'll see any computer that is connect to the same network you are and has sharing activated (even if it's password protected).
    If i'm missing what you're concerned about, let me know. Your question was worded pretty vaguely.

  • Nested Conditions in a Query or Priority setting

    Hi all
    Would anyone know whether it would be possible to do nested conditions or set the priority of conditions in a query?
    My problem is that I have two conditions, A and B. Both are optional, however, if both are entered together I want condition A to take effect before condition B.
    Example:
    Condition A is amount received (range)
    Condition B is Top N customers
    When both are entered together, I want to see the top N customers within the specified amount range.
    Currently, both conditions are together, meaning that if my specified range does not encompass the top N customers, I do not get any data retrieved.
    Any help on this would be appreciated and points awarded.
    Thanks in advance
    Nicholas

    I have exact same question that Nicholas Chia asked last year. Does anybody have any suggestions to achieve this?
    Here is the example scenario:
    CHAR          KF
    ABC          10
    BCD          -5
    CDE          0
    DEF          4
    EFG          6
    FGH          2
    IJK          -8
    Condition 1: Top 5
    Condition 2: Key figure <> 0
    I expect to see the results like this:
    CHAR          KF
    ABC          10
    BCD          -5
    DEF          4
    EFG          6
    FGH          2
    But, BEx outputs like this:
    CHAR          KF
    ABC          10
    DEF          4
    EFG          6
    FGH          2
    I think BEx is first applying the Top N condition. Takes the resulting data and then applies KF <> 0 condition.
    Is there a way to achieve the results the way we like (first apply condition 2 and then the condition 1). Creating the conditions in different order have no effect.

  • Problem in query writting , Need a help on priority

    Hi there,
    Please check the following scenario
    there are 2 tables
    event - eventId , userId and eventDate
    impression - impressionId,userId
    After joining -
    userId | impressionId | eventId | eventDate
    1 | 1 | null | null
    1 | 2 | null | null
    1 | 3 | 1 | 2007/08/10
    1 | 4 | null | null
    1 | 5 | null | null
    1 | 6 | null | null
    1 | 7 | 2 | 2007/08/10
    I want the following output to be generated.
    userId | impressionPosition | eventCnt
    1 | 3 | 1
    1 | 4 | 1 (2nd event occured AFTER 4 impressions)
    Please give some query clue or sample query.
    Thanks in Adv.
    -Amol Kashid

    you just need to add a partition clause to the analytic function:
    with t as (select 1 as userid, 1 as impressionid, null as eventid, null as eventdate from dual
    union all select 1, 2,null, null from dual
    union all select 1, 3,1, sysdate-5 from dual
    union all select 1, 4,null, null from dual
    union all select 1, 5,null, null from dual
    union all select 2, 6,2, sysdate from dual
    union all select 1, 7,2, sysdate from dual
    union all select 2, 8,2, sysdate from dual)
    select userid, count(*) over(partition by userid order by impressionid) event_sequence,
                                          'Event after '||
                                          to_char(nvl(impressionid - lag(impressionid) over (partition by userid order by impressionid),0))
                                          ||' impression(s)' as description
      from t
      where eventid is not null
        USERID EVENT_SEQUENCE DESCRIPTION
             1              1 Event after 0 impression(s)
             1              2 Event after 4 impression(s)
             2              1 Event after 0 impression(s)
             2              2 Event after 2 impression(s)
    4 rows selected.edit: actually, that screwed up the reporting of the first event.... hmmm....

  • Query to grouping on task priority for each employee

    Hi All,
    We have following table structure for employee, task & taskallocation.
    CREATE TABLE EMP
       (     "EMP_ID" NUMBER(10,0) NOT NULL ENABLE,
              "FNAME"     NVARCHAR2(50) NOT NULL ENABLE,
              "LNAME"     NVARCHAR2(50) NOT NULL ENABLE
    CREATE TABLE TASKS
       (     "TASK_ID" NUMBER(10,0) NOT NULL ENABLE,
              "TASK_PRIORITY" NVARCHAR2(10) NOT NULL ENABLE          
    CREATE TABLE TASKSALLOCATION
       (     "TASKALLOCATION_ID" NUMBER(10,0) NOT NULL ENABLE,
              "EMP_ID" NUMBER(10,0) NOT NULL ENABLE,
              "TASK_ID" NUMBER(10,0) NOT NULL ENABLE
       The data for the same will be as follows
    Insert into EMP (EMP_ID,FNAME,LNAME) values (1,'XYZ','DFD');
    Insert into EMP (EMP_ID,FNAME,LNAME) values (2,'DFDS','FD');
    Insert into EMP (EMP_ID,FNAME,LNAME) values (3,'FDSF','GFH');
    Insert into EMP (EMP_ID,FNAME,LNAME) values (6,'GFHGF','GFHS');
    Insert into EMP (EMP_ID,FNAME,LNAME) values (4,'GFD','FDG');
    Insert into EMP (EMP_ID,FNAME,LNAME) values (5,'DSFDS','FDSAF');
    Insert into EMP (EMP_ID,FNAME,LNAME) values (7,'GHGY','EWE');
    Insert into EMP (EMP_ID,FNAME,LNAME) values (8,'FGRFSAD','SADF');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (1,'HIGH');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (2,'MEDIUM');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (3,'LOW');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (4,'HIGH');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (5,'MEDIUM');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (6,'LOW');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (7,'HIGH');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (8,'MEDIUM');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (9,'LOW');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (10,'HIGH');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (11,'MEDIUM');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (12,'LOW');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (13,'HIGH');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (14,'MEDIUM');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (15,'LOW');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (16,'HIGH');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (17,'MEDIUM');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (18,'LOW');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (19,'HIGH');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (20,'MEDIUM');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (21,'LOW');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (22,'HIGH');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (23,'MEDIUM');
    Insert into TASKS (TASK_ID,TASK_PRIORITY) values (24,'LOW');
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (1,1,1);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (2,2,1);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (3,3,2);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (4,3,3);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (5,4,4);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (6,4,5);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (7,4,6);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (8,4,7);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (9,5,6);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (10,6,8);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (11,7,9);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (12,8,8);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (13,8,10);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (14,8,11);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (15,8,12);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (16,6,13);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (17,5,14);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (18,3,12);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (19,3,13);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (20,2,15);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (21,1,16);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (22,2,17);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (23,1,18);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (24,4,19);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (25,6,20);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (26,5,21);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (27,1,22);
    Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (28,3,23);
    COMMIT;And we are looking count of tasks based grouping on it's priority per employee. Something like this,
    Resultset
    with
        t as
              select     'XYZ DFD' as EMP_NAME,     3 as HIGH ,     0 as MEDIUM,     1 as LOW FROM dual union all
              select     'DFDS FD'     ,     1     ,     1     ,     1     FROM dual union all
              select     'FDSF GFH'     ,     1     ,     2     ,     2     FROM dual union all
              select     'GFHGF GFHS'     ,     3     ,     1     ,     1     FROM dual union all
              select     'GFD FDG'     ,     0     ,     1     ,     2     FROM dual union all
              select     'DSFDS FDSAF'     ,     1     ,     2     ,     0     FROM dual union all
              select     'GHGY EWE'     ,     0     ,     0     ,     1     FROM dual union all
              select     'FGRFSAD SADF'     ,     1     ,     2     ,     1     FROM dual)Note : We are using Oracle 11.2.0.2.0 version

    Hi,
    select emp.fname || ' ' || emp.lname EMP_NAME
         , sum(case when tasks.TASK_PRIORITY = 'HIGH' then 1 else 0 end) HIGH
         , sum(case when tasks.TASK_PRIORITY = 'MEDIUM' then 1 else 0 end) MEDIUM
         , sum(case when tasks.TASK_PRIORITY = 'LOW' then 1 else 0 end) LOW
      from emp
      join TASKSALLOCATION
        on emp.EMP_ID = TASKSALLOCATION.EMP_ID
      join TASKS
        on TASKSALLOCATION.TASK_ID = tasks.TASK_ID
    group by emp.fname || ' ' || emp.lname
    EMP_NAME                   HIGH     MEDIUM        LOW
    FGRFSAD SADF                  1          2          1
    XYZ DFD                       3          0          1
    GHGY EWE                      0          0          1
    GFHGF GFHS                    1          2          0
    GFD FDG                       3          1          1
    DFDS FD                       1          1          1
    FDSF GFH                      1          2          2
    DSFDS FDSAF                   0          1          2Regards
    Martin Preiss

  • Query:Pop up on login for incomplete high priority tasks in sap inbox

    Hi All,
    I am having requirement to display pop up for incomplete high priority in sap inbox on loging in sap.
    I wil be thankful if you can guide to fulfill this requirement.
    Thanks.

    Hi,
    To get the High priority work items you can use the table SWWWIHEAD.
    using this table you can get the Priority, Status, and agent of the work item. Using this you can build the logic to
    display the pop up with this details.
    Thanks,
    Viji.

  • Query - Variable Exit (High Priority)

    Hi Friends !
    I have the following requirement:
    <i>The user will have the capability to enter a Usage in months, which should filter the data from ZSCICC01 (summarize it to a value per material / plant).  This will be the sum of the amount of months listed from the last month (current month -1) and backwards. I.e. if the user enters 4 and the current month is May, then the usage totals will be the sum of Jan-Apr.  If this proves to be too complex to do, we can always give them a month range to chose their usage months from.</i>
    1) Do we have any Function Module to handle this situation?
    2) As the user input is numeric, how it can be handle by 0CALMONTH characteristic.
    Thanks,
    Rekha

    Hi Rekha,
    As per my understding of your question i am answereing this way.
    You can create this requirement with out ABAP code ,it can be selected Dynamically as per user input.
    follow the steps
    1)Create a variable name as (Y) based on Cal/year month
    2)select the same variable(Y-1) with offset as per your requirement .
    3)Here we should have two structure in key figure selections.
    let us know if the things are not clear
    Regards,
    suman

  • Where clause priority in Select Query

    Hi All,
    I have one doubt, Pls clarify
    SELECT empno, ename, sal, comm
    FROM emp E, dept D -- (deptno is pk for DEPT)
    WHERE D.deptno = E.deptno
    AND E.sal >= 3000
    In WHERE clause which one will execute first (right to left or left to right
    OR[b] First join conditions then after filter conditions or vice versa)
    D.deptno = E.deptno
    OR
    E.sal >= 3000
    (this is the example tables)
    Because I have large volume of data with 5 tables with joins
    so, pls. kindly give me the sugession for where clause.
    Thanks
    Naresh

    It depends, the order the where clause is written in makes no difference to how the statement is processed.
    In the section on Developing Efficient SQL Statements in the Performance Tuning Guide changing the order of statements in the where clause is notably missing.
    There is more information in the Understanding Joins section of the same manual.

  • Not able to input data in query analyzer

    Hi buddies,
    I am working on IP.I have created a input ready query.For few values of company code there is no transaction data available,but it should show us blank so that I can atleast punch data.I am able to punch data for company codes for which transaction data is avilable .For remaining company codes for which transaction data is not availbale it is showing yellow coloured rows not allowing to input data.
    Solutions would be really appreciated.This is high priority issue.
    With regards,
    Lalitha

    Hi,
    1) if you have no transaction data, it will not show you the company codes, unless you select in your query definition "master data' instead of posted values in the query properties (for company code)
    2) yellow lines are subtotals.... To enable it input ready
    - set query to input ready in query properties
    - set row to plannable in query properties
    - very important: make sure each characteristic of your aggregation level has a unique value either in the filter definition or in the definition of your rows or columns. If not, your query will not be plannable
    D

  • How to bind/pass multiple input parameters to sql query in BPEL Process

    Hi,
    I have a requirement to invoke a query on a database table to fetch the records based on the few input values or bind variables?
    I have created a Partner link using the DBAdapter service and have used custom SQL, how can i bind and pass multiple bind/input parameters for these queries.
    foreg: if i have to query employee records based on name , desgination and age, these three params would be my input parameter that i will pass when i invoke the BPEL process, bow how can i pass these parameters to the partner link using DBADAPTER service.
    Please help
    Regards

    If the parameter-value is not known beforehand and cannot be determined based on the process instance data at that time, there are 2 options. Either invoke the PL/SQL procedure you named using a DB adapter service to get the value and pass it to the other DB adapter service. Or create a single service (e.g. PL/SQL procedure) that determines the parameter value, executes the query and returns the result. However, this is more a design issue. Does it makes sense to combine these actions in a separate service and use it or are these actions not related? You furthermore state that additional (DB adapter) services make the process heavier. Do you have strict requirements on the time process-instances may run or other such requirements? If not, I think the design-choice on whether combining these actions in a single service should have more priority.

  • Sales Order + Activity query

    Hi,
    I set up the following query in one company:
    SELECT T0.DocNum, T1.ClgCode, T3.U_NAME, T2.name, T1.endDate, T1.Priority, T0.CardCode, T0.CardName, T0.NumAtCard, T0.DocDate, T0.DocTotal
    FROM ORDR T0 LEFT OUTER JOIN OCLG T1 ON T0.DocNum = T1.DocNum LEFT OUTER JOIN OCLA T2 ON T1.status = T2.statusID LEFT OUTER JOIN OUSR T3 ON T1.AttendUser = T3.INTERNAL_K
    WHERE T0.DocStatus = 'O'
    When I replicate it in another company, I get the following error:
    SQL Server Native Client 10.0|| SQL Server||  Conversion failed when converting the nvarchar value 'STBs-EN-0002' to data type int. 'Received Alerts' (OAIB)
    The STBs value indicated is an Item Code/IMD record which isn't even referred to in the query so not sure why it's getting picked up and/or causing an error.
    When I separate the two parts of the query - one query on just open sales orders, another on activities - they both work. It seems to be with the linking of ORDR to the Activities tables (if I try just ORDR and OCLG I get the same error above).
    Any assistance on figuring out how to fix the query would be much appreciated,
    Heather

    Hi Heather,
    Try:
    SELECT T0.DocNum, T1.ClgCode, T3.U_NAME, T2.name, T1.endDate, T1.Priority,
    T0.CardCode, T0.CardName, T0.NumAtCard, T0.DocDate, T0.DocTotal
    FROM ORDR T0
    LEFT JOIN OCLG T1 ON T0.DocNum = T1.DocNum AND T1.DocType = '17'
    LEFT JOIN OCLA T2 ON T1.status = T2.statusID
    LEFT JOIN OUSR T3 ON T1.AttendUser = T3.INTERNAL_K
    WHERE T0.DocStatus = 'O'
    Thanks,
    Gordon

  • Data driven subscription query returns no data

    We have a data driven subscription on SSRS 2008 R2. The columns in the query are tied to one or more parameters of the report. When we run the subscription and if the query does not return any rows, I was hoping that the subscription will not start; however,
    instead, to my surprise, I got error stating..."Parameter XYZ value can't be null". How to avoid this error and keep subscription from running in this situation? 
    Example: I have a report that required employeeID as a parameter. I have a query (step 3: data driven subscription) that fetches employee ID based on some criteria. If there is no row returned by the query; It throws error on report stating "Parameter
    EmployeeID can't be null."
    Nehal Jain

    Hello Nehal -
    Try adding a UNION ALL to your parameter dataset query like
    UNION ALL SELECT NULL AS EmployeeID , ..
    Just check accordingly. I ll revert again based on this , got a priority now.
    Happy to help! Thanks. Regards and good Wishes, Deepak. http://deepaksqlmsbusinessintelligence.blogspot.com/

  • Performance issue with a particular query

    Hi Experts,
    OS version : Sun solaris 5.10
    DB version : 10.1.0.4
    We have a report designed in SAP BO and for which we have below SQL query written
    SELECT
    SNOW_DIM.SERV_REP_INCIDENT.INCIDENT_NUMBER,
    ISAC_GL_APPL_HIERARCHY_SERVIMP.SOL_NAME
    ISAC_GL_APPL_HIERARCHY_SERVIMP.SOL_DOMAIN_NAME
    Count(DISTINCT SNOW_DIM.SERV_REP_INCIDENT.INCIDENT_NUMBER),
    Count(DISTINCT case when SNOW_DIM.SERV_REP_INCIDENT.STATE_ID=3 then SNOW_DIM.SERV_REP_INCIDENT.INCIDENT_NUMBER end),
    SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_GROUP,
    case when SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_SUPPORT_GROUP_LEVEL=1 then 'Level 1' when SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_SUPPORT_GROUP_LEVEL=2 then 'Level 2' when SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_SUPPORT_GROUP_LEVEL=3 then 'Level 3' else to_char(SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_SUPPORT_GROUP_LEVEL) end,
    SNOW_DIM.SERV_REP_INCIDENT.SHORT_DESCRIPTION,
    SNOW_DIM.SERV_REP_INCIDENT.PRIORITY,
    SNOW_DIM.SERV_REP_INCIDENT.STATE,
    SNOW_DIM.SERV_REP_INCIDENT.OPENED_AT,
    BU_EMPLOYEES_INC_AS.BUSINESS_NAME,
    TO_CHAR(SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT,'Month'),
    TO_CHAR(SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT,'MM'),
    TO_CHAR(SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT,'SYYYY'),
    SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT
    FROM
    SNOW_DIM.SERV_REP_INCIDENT,
    SNOW_DIM.ISAC_GL_APPL_HIERARCHY ISAC_GL_APPL_HIERARCHY_SERVIMP,
    SNOW_DIM.BU_EMPLOYEES BU_EMPLOYEES_INC_AS,
    SNOW_DIM.SERV_REP_CONTRACT_SLA,
    SNOW_DIM.SERV_REP_TASK_SLA
    WHERE
    ( SNOW_DIM.SERV_REP_INCIDENT.ASSIGNEE_GPN=BU_EMPLOYEES_INC_AS.GPN(+) )
    AND ( SNOW_DIM.SERV_REP_INCIDENT.INCIDENT_SYS_ID=SNOW_DIM.SERV_REP_TASK_SLA.TASK(+) )
    AND ( SNOW_DIM.SERV_REP_TASK_SLA.SLA=SNOW_DIM.SERV_REP_CONTRACT_SLA.SYS_ID(+) )
    AND ( ISAC_GL_APPL_HIERARCHY_SERVIMP.APPL_ID(+)=SNOW_DIM.SERV_REP_INCIDENT.SERVICE_ID )
    AND
    ISAC_GL_APPL_HIERARCHY_SERVIMP.APPL_ENVIRONMENT
    = 'PROD'
    AND
    SNOW_DIM.SERV_REP_INCIDENT.TYPE_X = 'Incident'
    AND
    case
    WHEN SNOW_DIM.SERV_REP_INCIDENT.DUPLICATE_INCIDENT = 1 then 'Yes'
    WHEN SNOW_DIM.SERV_REP_INCIDENT.DUPLICATE_INCIDENT = 0 then 'No'
    end = 'No'
    AND
    SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_GROUP IN ( 'WMSB_IT_CH_Business_Support_1_L2','WMSB_IT_CH_Business_Support_2_HW_L2','WMSB_IT_CH_Business_Support_2_L2','WMSB_IT_CH_Business_Support_3_L2','WMSB_IT_CH_Business_Support_4_CEFS_L2','WMSB_IT_CH_Business_Support_4_L2','WMSB_IT_CH_Business_Support_5_L2','WMSB_IT_APAC_Production_Support_L2','WMSB_IT_EMEA_ESS_CLAS_Team_L2','WMSB_IT_US_Production_Support_L2','WMSB_IT_CH_AoC_Decentral_L2','WMSB_IT_CH_AoC_Mainframe_L2','WMSB_IT_GLOB_AoC_Decentral_L2' )
    OR
    SNOW_DIM.SERV_REP_CONTRACT_SLA.TYPE_X = 'SLA'
    AND
    SNOW_DIM.SERV_REP_TASK_SLA.STAGE IN ( 'in_progress','achieved','breached','completed','paused' )
    OR
    SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_GROUP NOT IN ( 'WMSB_IT_CH_Business_Support_1_L2','WMSB_IT_CH_Business_Support_2_HW_L2','WMSB_IT_CH_Business_Support_2_L2','WMSB_IT_CH_Business_Support_3_L2','WMSB_IT_CH_Business_Support_4_CEFS_L2','WMSB_IT_CH_Business_Support_4_L2','WMSB_IT_CH_Business_Support_5_L2','WMSB_IT_APAC_Production_Support_L2','WMSB_IT_EMEA_ESS_CLAS_Team_L2','WMSB_IT_US_Production_Support_L2','WMSB_IT_CH_AoC_Decentral_L2','WMSB_IT_CH_AoC_Mainframe_L2','WMSB_IT_GLOB_AoC_Decentral_L2','WMSB_IT_GLOB_Service_Desk_L1','WMSB_IT_EMEA_ESS_CLAS_Team_L1' )
    AND
    SNOW_DIM.SERV_REP_TASK_SLA.ASSIGNMENT_GROUP_NAME IN ( 'WMSB_IT_CH_Business_Support_1_L2','WMSB_IT_CH_Business_Support_2_HW_L2','WMSB_IT_CH_Business_Support_2_L2','WMSB_IT_CH_Business_Support_3_L2','WMSB_IT_CH_Business_Support_4_CEFS_L2','WMSB_IT_CH_Business_Support_4_L2','WMSB_IT_CH_Business_Support_5_L2','WMSB_IT_APAC_Production_Support_L2','WMSB_IT_EMEA_ESS_CLAS_Team_L2','WMSB_IT_US_Production_Support_L2','WMSB_IT_CH_AoC_Decentral_L2','WMSB_IT_CH_AoC_Mainframe_L2','WMSB_IT_GLOB_AoC_Decentral_L2' )
    AND
    SNOW_DIM.SERV_REP_TASK_SLA.STAGE IN ( 'in_progress','achieved','breached','completed','paused' )
    AND
    ISAC_GL_APPL_HIERARCHY_SERVIMP.SOL_DOMAIN_NAME
    IN ('Partner, Product & Contract Management')
    AND
    SNOW_DIM.SERV_REP_INCIDENT.STATE IN ( 'Assigned','Closed','In Progress','New','On Hold','Resolved' )
    AND
    ( ( SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT ) between (ADD_MONTHS(trunc(sysdate,'MM'),-6)) AND (trunc(sysdate,'MM')-0.0002/24)
    GROUP BY
    SNOW_DIM.SERV_REP_INCIDENT.INCIDENT_NUMBER,
    ISAC_GL_APPL_HIERARCHY_SERVIMP.SOL_NAME
    ISAC_GL_APPL_HIERARCHY_SERVIMP.SOL_DOMAIN_NAME
    SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_GROUP,
    case when SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_SUPPORT_GROUP_LEVEL=1 then 'Level 1' when SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_SUPPORT_GROUP_LEVEL=2 then 'Level 2' when SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_SUPPORT_GROUP_LEVEL=3 then 'Level 3' else to_char(SNOW_DIM.SERV_REP_INCIDENT.ASSIGNED_SUPPORT_GROUP_LEVEL) end,
    SNOW_DIM.SERV_REP_INCIDENT.SHORT_DESCRIPTION,
    SNOW_DIM.SERV_REP_INCIDENT.PRIORITY,
    SNOW_DIM.SERV_REP_INCIDENT.STATE,
    SNOW_DIM.SERV_REP_INCIDENT.OPENED_AT,
    BU_EMPLOYEES_INC_AS.BUSINESS_NAME,
    TO_CHAR(SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT,'Month'),
    TO_CHAR(SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT,'MM'),
    TO_CHAR(SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT,'SYYYY'),
    SNOW_DIM.SERV_REP_INCIDENT.CLOSED_AT;
    Users reporting that the report is running slow and I have generated explain plan for the same and it is as below
    PLAN_TABLE_OUTPUT
    Plan hash value: 2068297582
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 13216 | 38M| | 245K (1)| 00:13:02 |
    | 1 | SORT GROUP BY | | 13216 | 38M| 103M| 245K (1)| 00:13:02 |
    |* 2 | FILTER | | | | | | |
    | 3 | NESTED LOOPS OUTER | | 13216 | 38M| | 232K (1)| 00:12:21 |
    |* 4 | FILTER | | | | | | |
    | 5 | NESTED LOOPS OUTER | | 508 | 1495K| | 232K (1)| 00:12:21 |
    |* 6 | FILTER | | | | | | |
    | 7 | NESTED LOOPS OUTER | | 508 | 1477K| | 232K (1)| 00:12:21 |
    |* 8 | HASH JOIN | | 96 | 270K| | 232K (1)| 00:12:21 |
    |* 9 | MAT_VIEW ACCESS FULL | ISAC_GL_APPL_HIERARCHY | 6 | 4230 | | 3884 (1)| 00:00:13 |
    |* 10 | TABLE ACCESS BY INDEX ROWID| SERV_REP_INCIDENT | 802K| 1669M| | 228K (1)| 00:12:08 |
    |* 11 | INDEX RANGE SCAN | I7_SERV_REP_INCIDENT_N | 1368K| | | 3437 (3)| 00:00:11 |
    | 12 | TABLE ACCESS BY INDEX ROWID | SERV_REP_TASK_SLA | 5 | 455 | | 1 (0)| 00:00:01 |
    |* 13 | INDEX RANGE SCAN | I6_SERV_REP_TASK_SLA | 5 | | | 0 (0)| 00:00:01 |
    | 14 | TABLE ACCESS BY INDEX ROWID | SERV_REP_CONTRACT_SLA | 1 | 37 | | 1 (0)| 00:00:01 |
    |* 15 | INDEX RANGE SCAN | I1_SERV_REP_CONTRACT_SLA | 1 | | | 0 (0)| 00:00:01 |
    | 16 | TABLE ACCESS BY INDEX ROWID | BU_EMPLOYEES | 26 | 858 | | 1 (0)| 00:00:01 |
    |* 17 | INDEX RANGE SCAN | I01_BU_EMPLOYEES | 26 | | | 0 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter(ADD_MONTHS(TRUNC(SYSDATE@!,'fmmm'),-6)<=TRUNC(SYSDATE@!,'fmmm')-.000011574074074074074074074074074
    07407407407)
    4 - filter("SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_APAC_Production_Support_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_AoC_Decentral_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_AoC_Mainframe_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_Business_Support_1_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_Business_Support_2_HW_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_Business_Support_2_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_Business_Support_3_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_Business_Support_4_CEFS_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_Business_Support_4_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_CH_Business_Support_5_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_EMEA_ESS_CLAS_Team_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_GLOB_AoC_Decentral_L2' OR
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"='WMSB_IT_US_Production_Support_L2' OR "T"."TYPE_X"='SLA' AND
    ("SERV_REP_TASK_SLA"."STAGE"='achieved' OR "SERV_REP_TASK_SLA"."STAGE"='breached' OR
    "SERV_REP_TASK_SLA"."STAGE"='completed' OR "SERV_REP_TASK_SLA"."STAGE"='in_progress' OR
    "SERV_REP_TASK_SLA"."STAGE"='paused') OR ("SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_APAC_Production_S
    upport_L2' OR "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_AoC_Decentral_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_AoC_Mainframe_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_Business_Support_1_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_Business_Support_2_HW_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_Business_Support_2_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_Business_Support_3_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_Business_Support_4_CEFS_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_Business_Support_4_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_CH_Business_Support_5_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_EMEA_ESS_CLAS_Team_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_GLOB_AoC_Decentral_L2' OR
    "SERV_REP_TASK_SLA"."ASSIGNMENT_GROUP_NAME"='WMSB_IT_US_Production_Support_L2') AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_Business_Support_1_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_Business_Support_2_HW_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_Business_Support_2_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_Business_Support_3_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_Business_Support_4_CEFS_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_Business_Support_4_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_Business_Support_5_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_APAC_Production_Support_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_EMEA_ESS_CLAS_Team_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_US_Production_Support_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_AoC_Decentral_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_CH_AoC_Mainframe_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_GLOB_AoC_Decentral_L2' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_GLOB_Service_Desk_L1' AND
    "SERV_REP_INCIDENT"."ASSIGNED_GROUP"<>'WMSB_IT_EMEA_ESS_CLAS_Team_L1')
    6 - filter("SERV_REP_TASK_SLA"."STAGE"='achieved' OR "SERV_REP_TASK_SLA"."STAGE"='breached' OR
    "SERV_REP_TASK_SLA"."STAGE"='completed' OR "SERV_REP_TASK_SLA"."STAGE"='in_progress' OR
    "SERV_REP_TASK_SLA"."STAGE"='paused')
    8 - access("ISAC_GL_APPL_HIERARCHY_SERVIMP"."APPL_ID"="SERV_REP_INCIDENT"."SERVICE_ID")
    9 - filter("ISAC_GL_APPL_HIERARCHY_SERVIMP"."APPL_ENVIRONMENT"='PROD' AND
    "ISAC_GL_APPL_HIERARCHY_SERVIMP"."SOL_DOMAIN_NAME"='Partner, Product & Contract Management')
    10 - filter("SERV_REP_INCIDENT"."TYPE_X"='Incident' AND ("SERV_REP_INCIDENT"."STATE"='Assigned' OR
    "SERV_REP_INCIDENT"."STATE"='Closed' OR "SERV_REP_INCIDENT"."STATE"='In Progress' OR
    "SERV_REP_INCIDENT"."STATE"='New' OR "SERV_REP_INCIDENT"."STATE"='On Hold' OR
    "SERV_REP_INCIDENT"."STATE"='Resolved') AND CASE "SERV_REP_INCIDENT"."DUPLICATE_INCIDENT" WHEN 1 THEN 'Yes'
    WHEN 0 THEN 'No' END ='No')
    11 - access("SERV_REP_INCIDENT"."CLOSED_AT">=ADD_MONTHS(TRUNC(SYSDATE@!,'fmmm'),-6) AND
    "SERV_REP_INCIDENT"."CLOSED_AT"<=TRUNC(SYSDATE@!,'fmmm')-.00001157407407407407407407407407407407407407)
    13 - access("SERV_REP_INCIDENT"."INCIDENT_SYS_ID"="SERV_REP_TASK_SLA"."TASK"(+))
    15 - access("SERV_REP_TASK_SLA"."SLA"="T"."SYS_ID"(+))
    17 - access("SERV_REP_INCIDENT"."ASSIGNEE_GPN"="T"."GPN"(+))
    From above plan I could analyze that indexes on table SERV_REP_INCIDENT are not being used on columns ASSIGNED_GROUP, STATE, STAGE etc as they are using IN and NOT IN clauses in where condition and because of this reason cost at id 10 increased to 228k.
    now, i would like to know the advise from you people what can be done to make it better. also I read that IN clause can use indexes if data is more. In my case is there any way that I can force those IN and NOT IN clauses to use index? (we have indexes created on all those columns used by SERV_REP_INCIDENT table)
    Thanks in advance.

    From above plan I could analyze that indexes on table SERV_REP_INCIDENT are not being used on columns ASSIGNED_GROUP, STATE, STAGE etc as they are using IN and NOT IN clauses in where condition and >because of this reason cost at id 10 increased to 228k.Good job isolating the (estimated) spike in resources by high estimates! You can try to minimize the work for this step in several ways, some simple and some extreme:
    Try a composite function-based index on SERV_REP_INCIDENT for the IN clauses.
    Another long-term possiblity is to partition the SERV_REP_INCIDENT table by the IN values if you have the license. This may not be the best partionining option; partitioning needs to be conisdered carefully before implementation.
    How long does the query take to execute? Another possiblity is to to create a materialized view on the query you posted, using the automated query rewrite to automatically use it (possibly indexed).

Maybe you are looking for

  • Trouble with Multiple devices and Ical

    I have one itunes account that is shared with a myself and my kids ipod. I have created a calendar for each kid and their activities. I was trying to share this calendar only with the specific ipod, which seems to work. the issue is they are still ge

  • How to do File Comparison in SAP PI

    Hi All, I have another requirement. I have two text files, both containing a list of materials. I want to compare file A with file B and add the materials from file B that are not in file A. For example Input: File A           15-G 12-B 18-A 18-D Inp

  • Connectivity between MacPro and MacBook

    I have a MacPro (bought in 2011) and have just bought a new MacBook Pro. Is there any way I can connect the two so as to sync the work done during the day on my MacBook to the Pro? the guy in the store sold me a Thunderbolt to Thunderbolt cable and t

  • Objects missing in database (views)

    As information/background, I have been away from SAP and basis for about four years.  Due to personnel changes here, I am now returning to it. While I was away, our SAP system was upgraded from version 4.0B to “SAP R/3 ENTERPRISE 47X110”.  I was not

  • Saving PDF with Form

    I've got a PDF with several form fields, if I fill them out and save the PDF, all of the fields go blank again. I have access to Acrobat Pro on another computer so I can tell that this PDF has no protections enabled, what's wrong?