Query Tunning Problem

I am using oracle Db 9.2.4 ,
Beloq query is taking lot of time ie.5mins, can anybody help me to tune the query....
SELECT    LTRIM
             (RTRIM (   DECODE (tit_name,
                                'MR.', 'CA.',
                                'MS.', 'CA.',
                                'MRS.', 'CA.'
                     || ' '
                     || mrh_first_name
                     || ' '
                     || mrh_middle_name
                     || ' '
                     || mrh_sur_name
                     || ' '
                     || DECODE (mrh_appr_uid,
                                NULL, NULL,
                                DECODE (mrh_mem_status,
                                        2, NULL,
                                        DECODE (mrh_fellow_status_yn,
                                                'Y', 'FCA',
                                                'ACA'
                     || DECODE (mrh_resi_status,
                                'A', '                         AIR - MAIL'
                     || CHR (10)
       || DECODE (mrh_cop_status,
                  1, DECODE (mrh_cop_type,
                             13, 'CHARTERED ACCOUNTANT' || CHR (10),
                             NULL
                  NULL
       || LTRIM (RTRIM (mrh_prof_addr_line_1))
       || DECODE (mrh_prof_addr_line_1, NULL, NULL, CHR (10))
       || LTRIM (RTRIM (mrh_prof_addr_line_2))
       || DECODE (mrh_prof_addr_line_2, NULL, NULL, CHR (10))
       || LTRIM (RTRIM (mrh_prof_addr_line_3))
       || DECODE (mrh_prof_addr_line_3, NULL, NULL, CHR (10))
       || LTRIM (RTRIM (mrh_prof_addr_line_4))
       || DECODE (mrh_prof_addr_line_4, NULL, NULL, CHR (10))
       || LTRIM (RTRIM (   city_name
                        || '-'
                        || mrh_prof_zip_postal_code
                        || DECODE (mrh_resi_status,
                                   'A', CHR (10) || cou_name,
                                   NULL
                ) l_common,
       DECODE (mrh_appr_uid, NULL, 'T', 'P') p_t_flag
  FROM cadata3.om_mem_reg_head, cadata3.om_city, cadata3.om_country, cadata3.om_title
WHERE cou_code = mrh_prof_cou_code
   AND city_code = mrh_prof_city_code(+)
   AND mrh_title = tit_code(+)
   AND NVL (mrh_clo_status, 0) != 1
164245 rows selected.
Elapsed: 00:04:26.09
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id  | Operation                |  Name                  | Rows  | Bytes |TempS
pc| Cost  | Pstart| Pstop |
|   0 | SELECT STATEMENT         |                        |   164K|    25M|
PLAN_TABLE_OUTPUT
  |  2332 |       |       |
|   1 |  HASH JOIN               |                        |   164K|    25M|
  |  2332 |       |       |
|   2 |   TABLE ACCESS FULL      | OM_COUNTRY             |   676 | 12168 |
  |     3 |       |       |
|   3 |   HASH JOIN OUTER        |                        |   164K|    22M|    2
3M|  2296 |       |       |
PLAN_TABLE_OUTPUT
|   4 |    FILTER                |                        |       |       |
  |       |       |       |
|   5 |     HASH JOIN OUTER      |                        |       |       |
  |       |       |       |
|   6 |      INDEX FAST FULL SCAN| IDM_OM_CITY_CITY_NAME  | 24226 |   449K|
  |    11 |       |       |
|   7 |      PARTITION LIST ALL  |                        |       |       |
  |       |     1 |     7 |
PLAN_TABLE_OUTPUT
|   8 |       TABLE ACCESS FULL  | OM_MEM_REG_HEAD        |   164K|    18M|
  |  1155 |     1 |     7 |
|   9 |    TABLE ACCESS FULL     | OM_TITLE               |     8 |    88 |
  |     2 |       |       |
PLAN_TABLE_OUTPUT
Note: cpu costing is off, 'PLAN_TABLE' is old version
17 rows selected.
SQL>
SQL> select index_name, COLUMN_NAMe,column_position from  dba_ind_columns where
table_name='OM_MEM_REG_HEAD' and column_name like 'MRH_PROF%';
INDEX_NAME
COLUMN_NAME
COLUMN_POSITION
IDM_MRH_PROF_CITY2
MRH_PROF_CITY_CODE
              1
ABC
MRH_PROF_REGION_CODE
              1
INDEX_NAME
COLUMN_NAME
COLUMN_POSITION
---------------After using an index hint in the query of the table OM_MEM_REG_HEAD, timing of the query goes down to 3.5 mins,pls suggest me to tune the query so that the timing of the query goes down.....

Pls find a tkprof report
TKPROF: Release 9.2.0.4.0 - Production on Mon Aug 18 11:53:08 2008
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
Trace file: G:\oracle\admin\hotest\udump\hotest_ora_3216.trc
Sort options: prsela  exeela  fchela 
count    = number of times OCI procedure was executed
cpu      = cpu time in seconds executing
elapsed  = elapsed time in seconds executing
disk     = number of physical reads of buffers from disk
query    = number of buffers gotten for consistent read
current  = number of buffers gotten in current mode (usually for update)
rows     = number of rows processed by the fetch or execute call
SELECT    LTRIM
             (RTRIM (   DECODE (tit_name,
                                'MR.', 'CA.',
                                'MS.', 'CA.',
                                'MRS.', 'CA.'
                     || ' '
                     || mrh_first_name
                     || ' '
                     || mrh_middle_name
                     || ' '
                     || mrh_sur_name
                     || ' '
                     || DECODE (mrh_appr_uid,
                                NULL, NULL,
                                DECODE (mrh_mem_status,
                                        2, NULL,
                                        DECODE (mrh_fellow_status_yn,
                                                'Y', 'FCA',
                                                'ACA'
                     || DECODE (mrh_resi_status,
                                'A', '                         AIR - MAIL'
                     || CHR (10)
       || DECODE (mrh_cop_status,
                  1, DECODE (mrh_cop_type,
                             13, 'CHARTERED ACCOUNTANT' || CHR (10),
                             NULL
                  NULL
       || LTRIM (RTRIM (mrh_prof_addr_line_1))
       || DECODE (mrh_prof_addr_line_1, NULL, NULL, CHR (10))
       || LTRIM (RTRIM (mrh_prof_addr_line_2))
       || DECODE (mrh_prof_addr_line_2, NULL, NULL, CHR (10))
       || LTRIM (RTRIM (mrh_prof_addr_line_3))
       || DECODE (mrh_prof_addr_line_3, NULL, NULL, CHR (10))
       || LTRIM (RTRIM (mrh_prof_addr_line_4))
       || DECODE (mrh_prof_addr_line_4, NULL, NULL, CHR (10))
       || LTRIM (RTRIM (   city_name
                        || '-'
                        || mrh_prof_zip_postal_code
                        || DECODE (mrh_resi_status,
                                   'A', CHR (10) || cou_name,
                                   NULL
                ) l_common,
       DECODE (mrh_appr_uid, NULL, 'T', 'P') p_t_flag
  FROM om_mem_reg_head, om_city, om_country, om_title
WHERE cou_code = mrh_prof_cou_code
   AND city_code = mrh_prof_city_code(+)
   AND mrh_title = tit_code(+)
   AND NVL (mrh_clo_status, 0) != 1
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call     count       cpu    elapsed       disk      query    current        rows
Parse        4      0.01       0.05          2         16          0           0
Execute      5      0.00       0.03          0          0          0           0
Fetch    10258      4.78      23.62      12420      12157          0      153818
total    10267      4.79      23.72      12422      12173          0      153818
Misses in library cache during parse: 3
Misses in library cache during execute: 1
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call     count       cpu    elapsed       disk      query    current        rows
Parse        9      0.00       0.00          0          0          0           0
Execute     10      0.00       0.00          0          0          0           0
Fetch       10      0.00       0.06          5         21          0           8
total       29      0.00       0.06          5         21          0           8
Misses in library cache during parse: 2
    5  user  SQL statements in session.
    9  internal SQL statements in session.
   14  SQL statements in session.
Trace file: G:\oracle\admin\hotest\udump\hotest_ora_3216.trc
Trace file compatibility: 9.00.01
Sort options: prsela  exeela  fchela 
       1  session in tracefile.
       5  user  SQL statements in trace file.
       9  internal SQL statements in trace file.
      14  SQL statements in trace file.
       6  unique SQL statements in trace file.
   10522  lines in trace file.here we can easily seen rows/call is much greater than elapsed/call......
pls suggest...

Similar Messages

  • Help me query tunning

    Hi Guru's
    Can you please help me query tunning.
    Database Version : Oracle 11g - 11.2.0.3
    select  distinct  corporation_name custer_name,
            glog_util.remove_domain(SHIP_BUY.SERVPROV_GID ) SCAC,
            glog_util.remove_domain(ship_buy.shipment_gid) buy_shipment_gid,
            F_Get_SELL_ID_STRING(SHIP_BUY.SHIPMENT_GID) sell_shipment_gid,
            ship_buy.domain_name,    
            F_GET_ORDER_RELEASE_GID('B',SHIP_BUY.SHIPMENT_GID,0) ORDER_RELEASE_GID,
            f_get_refnum_string('SHIPMENT', ship_buy.shipment_gid, 'MBOL_NUMBER_CLEANSED')MBOL_NUMBER,
            F_GET_POD_RECEIVED_DATE (ship_BUY.SHIPMENT_GID) POD_RECEIVED_DATE,
            f_get_exp_accrue_amt(ship_buy.shipment_gid,'SHIPMENT') Total_accrual_amount    
    from shipment ship_buy,
            invoice inv,
            invoice_shipment si,
            --voucher v,
            corporation corp
    where corp.domain_name=ship_buy.domain_name
            and corp.is_domain_master='Y'
          and 1=1
          AND ship_buy.domain_name like 'UPS/CP/DFP/%'
          and F_GET_POD_RECEIVED_DATE (ship_BUY.SHIPMENT_GID)  <= to_char(to_date('31-JUL-2013', 'DD-MON-YYYY'), 'dd-mon-yyyy')
            --and V.INVOICE_GID(+) = inv.invoice_gid
            --and ship_buy.domain_name = 'UPS/CP/VZNB'
            and si.shipment_gid(+) = SHIP_BUY.SHIPMENT_GID
            AND SI.INVOICE_GID = INV.INVOICE_GID(+)
            and SHIP_BUY.INSERT_DATE > '1-JAN-2007'
            and SHIP_BUY.USER_DEFINED1_ICON_GID = 'ACCEPTED'
    UNION        
    select  distinct  corporation_name custer_name,
            glog_util.remove_domain(SHIP_BUY.SERVPROV_GID ) SCAC,
            glog_util.remove_domain(ship_buy.shipment_gid) buy_shipment_gid,
            F_GET_SELL_ID_STRING( SHIP_BUY.SHIPMENT_GID) sell_shipment_gid,
            ship_buy.domain_name,    
            F_GET_ORDER_RELEASE_GID('B',SHIP_BUY.SHIPMENT_GID,0) ORDER_RELEASE_GID,
            f_get_refnum_string('SHIPMENT', ship_buy.shipment_gid, 'MBOL_NUMBER_CLEANSED')MBOL_NUMBER,
            F_GET_POD_RECEIVED_DATE (ship_BUY.SHIPMENT_GID) POD_RECEIVED_DATE,
            f_get_exp_accrue_amt(inv.invoice_gid,'INVOICE') Total_accrual_amount  
    from shipment ship_buy,
            invoice inv,
            invoice_shipment si,
          -- voucher v,
            corporation corp
    where corp.domain_name=ship_buy.domain_name
            and corp.is_domain_master='Y'
            and 1=1
            AND ship_buy.domain_name like 'UPS/CP/DFP/%'
            and F_GET_POD_RECEIVED_DATE (ship_BUY.SHIPMENT_GID)  <= to_char(to_date('31-JUL-2013', 'DD-MON-YYYY'), 'dd-mon-yyyy')
          --AND INV.DOMAIN_NAME = 'UPS/CP/VZNB'
          --and V.INVOICE_GID(+) = inv.invoice_gid
            and si.shipment_gid(+) = SHIP_BUY.SHIPMENT_GID
            AND SI.INVOICE_GID = INV.INVOICE_GID(+)
            and SHIP_BUY.INSERT_DATE > '1-JAN-2007'
            and INV.USER_DEFINED1_ICON_GID = 'ACCEPTED'
    GROUP BY corporation_name,SHIP_BUY.SHIPMENT_GID,SHIP_BUY.SERVPROV_GID,ship_buy.domain_name,inv.invoice_gid
    ORDER BY CUSTER_NAME, BUY_SHIPMENT_GID;
    And I generated the execution plan :
    | Id  | Operation                          | Name                    | Rows  | Bytes | Cost (%CPU)| Time    |
    |  0 | SELECT STATEMENT                  |                        |    3 |  448 |  415  (2)| 00:00:05 |
    |  1 |  SORT UNIQUE                      |                        |    3 |  448 |  414  (87)| 00:00:05 |
    |  2 |  UNION-ALL                        |                        |      |      |            |          |
    |  3 |    NESTED LOOPS OUTER              |                        |    3 |  384 |    57  (0)| 00:00:01 |
    |*  4 |    HASH JOIN                      |                        |    3 |  294 |    54  (0)| 00:00:01 |
    |*  5 |      TABLE ACCESS BY INDEX ROWID  | SHIPMENT                |    3 |  195 |    40  (0)| 00:00:01 |
    |*  6 |      INDEX SKIP SCAN              | IND_SHIP_DOM_ICON      |    54 |      |    25  (0)| 00:00:01 |
    |*  7 |      TABLE ACCESS FULL            | CORPORATION            |    4 |  132 |    14  (0)| 00:00:01 |
    |*  8 |    INDEX RANGE SCAN              | IND_INVOICESHIP_SHP_GID |    1 |    30 |    1  (0)| 00:00:01 |
    |  9 |    HASH GROUP BY                  |                        |    1 |  192 |  356  (1)| 00:00:05 |
    |* 10 |    HASH JOIN                      |                        |    1 |  192 |  354  (1)| 00:00:05 |
    |  11 |      NESTED LOOPS                  |                        |      |      |            |          |
    |  12 |      NESTED LOOPS                |                        |    1 |  159 |  339  (0)| 00:00:05 |
    |  13 |        NESTED LOOPS                |                        |  145 | 13920 |  194  (0)| 00:00:03 |
    |  14 |        TABLE ACCESS BY INDEX ROWID| INVOICE                |  145 |  5220 |    49  (0)| 00:00:01 |
    |* 15 |          INDEX SKIP SCAN          | IDX_INV_TYP_ICON_NAM    |  145 |      |    17  (0)| 00:00:01 |
    |* 16 |        INDEX RANGE SCAN          | UK_INVOICE_SHIPMENT    |    1 |    60 |    1  (0)| 00:00:01 |
    |* 17 |        INDEX UNIQUE SCAN          | PK_SHIPMENT            |    1 |      |    1  (0)| 00:00:01 |
    |* 18 |      TABLE ACCESS BY INDEX ROWID  | SHIPMENT                |    1 |    63 |    1  (0)| 00:00:01 |
    |* 19 |      TABLE ACCESS FULL            | CORPORATION            |    4 |  132 |    14  (0)| 00:00:01 |
    Predicate Information (identified by operation id):
      4 - access("CORP"."DOMAIN_NAME"="SHIP_BUY"."DOMAIN_NAME")
      5 - filter("F_GET_POD_RECEIVED_DATE"("SHIP_BUY"."SHIPMENT_GID")<=TO_DATE(' 2013-07-31 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss') AND "SHIP_BUY"."INSERT_DATE">TO_DATE(' 2007-01-01 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss'))
      6 - access("SHIP_BUY"."USER_DEFINED1_ICON_GID"='ACCEPTED' AND "SHIP_BUY"."DOMAIN_NAME" LIKE
                  'UPS/CP/DFP/%')
          filter("SHIP_BUY"."DOMAIN_NAME" LIKE 'UPS/CP/DFP/%' AND
                  "SHIP_BUY"."USER_DEFINED1_ICON_GID"='ACCEPTED')
      7 - filter("CORP"."IS_DOMAIN_MASTER"='Y' AND "CORP"."DOMAIN_NAME" LIKE 'UPS/CP/DFP/%')
      8 - access("SI"."SHIPMENT_GID"(+)="SHIP_BUY"."SHIPMENT_GID")
      10 - access("CORP"."DOMAIN_NAME"="SHIP_BUY"."DOMAIN_NAME")
      15 - access("INV"."USER_DEFINED1_ICON_GID"='ACCEPTED')
          filter("INV"."USER_DEFINED1_ICON_GID"='ACCEPTED')
      16 - access("SI"."INVOICE_GID"="INV"."INVOICE_GID")
      17 - access("SI"."SHIPMENT_GID"="SHIP_BUY"."SHIPMENT_GID")
          filter("F_GET_POD_RECEIVED_DATE"("SHIP_BUY"."SHIPMENT_GID")<=TO_DATE(' 2013-07-31 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss'))
      18 - filter("SHIP_BUY"."DOMAIN_NAME" LIKE 'UPS/CP/DFP/%' AND "SHIP_BUY"."INSERT_DATE">TO_DATE('
                  2007-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      19 - filter("CORP"."IS_DOMAIN_MASTER"='Y' AND "CORP"."DOMAIN_NAME" LIKE 'UPS/CP/DFP/%')
    Statistics
        246247  recursive calls
              2  db block gets
        1660067  consistent gets
          13839  physical reads
              0  redo size
        592054  bytes sent via SQL*Net to client
          6024  bytes received via SQL*Net from client
            502  SQL*Net roundtrips to/from client
          15296  sorts (memory)
              0  sorts (disk)
          7513  rows processed

    Hmmm...why does this look familiar?
    F_GET_POD_RECEIVED_DATE (ship_BUY.SHIPMENT_GID)  <= to_char(to_date('31-JUL-2013', 'DD-MON-YYYY'), 'dd-mon-yyyy')
    SHIP_BUY.INSERT_DATE > '1-JAN-2007'
    Like I said in your other thread about this, these two lines need to be fixed and your function needs to be fixed so the return statement doesn't do an implicit date conversion.
    Can't you see what that first line is doing?  You're taking a character string, turning it into a date, then back to a character string.
    If nothing else, these lines should be...
    F_GET_POD_RECEIVED_DATE (ship_BUY.SHIPMENT_GID)  <= to_date('31-JUL-2013', 'DD-MON-YYYY')
    SHIP_BUY.INSERT_DATE > to_date('01-JAN-2007','DD-MON-YYYY')
    (assuming insert_date is a proper date format, fingers crossed)

  • About query related problem

    hi ,
           we are generate query in 2005b,and procced for execuite query.following problem occure'<b>odbc sql server driver'[sql server] syntax error the converting the nvarchar value' 70302/20307' to column of data type int received alert OAIB</b>
    QUERY SHOWN BE AS FOLLOW.
    SELECT T5.DocNum as'Po. No. ', T5.DocDate as 'Po Date',T0.CreateDate,T5.NumAtCard as 'Man.PO. No/ Dt.', T0.DocNum as'AP No. ', T0.DocDate as 'AP Date',T0.NumAtCard as 'Vendor Ref. No.', T0.U_vbdt as 'Vendor Ref. Date', T0.CardName as 'Vendor', T1.Dscription as 'Item',  T1.Quantity AS 'QTY'  , T1.Price as 'Basic Rate', (T1.Price *T1.Quantity) as 'Value',T0.Comments as 'Po No. & Po.Dt.' FROM OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OPDN T3 ON T2.CardCode = T3.CardCode INNER JOIN PDN1 T4 ON T3.DocEntry = T4.DocEntry INNER JOIN OPOR T5 ON T2.CardCode = T5.CardCode INNER JOIN POR1 T6 ON T5.DocEntry = T6.DocEntry INNER JOIN OITM T7 ON T1.ItemCode = T7.ItemCode INNER JOIN OITB T8 ON T7.ItmsGrpCod = T8.ItmsGrpCod WHERE (  T1.BaseRef  =  T3.DocNum )  AND ( T4.BaseRef =  T5.DocNum ) AND (  T0.U_vbdt >=[%25]AND  T0.U_vbdt <=[%26]) AND ( T4.Dscription =T1.Dscription ) AND ( T4.Dscription = T6.Dscription  ) AND  (( T1.Dscription=[%0] OR T1.Dscription=[%1] OR T1.Dscription=[%2] OR T1.Dscription=[%3] OR T1.Dscription=[%4] OR T1.Dscription=[%5] OR T1.Dscription=[%6] OR T1.Dscription=[%7] OR T1.Dscription=[%8] ) OR ( T0.CardName=[%10] OR T0.CardName=[%09] OR T0.CardName=[%27] OR T0.CardName=[%28] ) OR ((  T8.ItmsGrpNam =[%11]  oR T8.ItmsGrpNam =[%12] OR T8.ItmsGrpNam =[%13] OR T8.ItmsGrpNam =[%14] OR T8.ItmsGrpNam =[%15] OR T8.ItmsGrpNam =[%16] OR T8.ItmsGrpNam =[%17] OR T8.ItmsGrpNam =[%18] OR T8.ItmsGrpNam =[%19] ) and  ( T7.U_FirmName =[%20] OR T7.U_FirmName =[%21] OR T7.U_FirmName =[%22] 
    oR T7.U_FirmName =[%23] OR T7.U_FirmName =[%24] )) )

    Hi Vishal,
    the value '70302/20307' is not an whole number so converting it to an int is not possible.
    You should check your data for this value an change your query or data.
    Regards
    Ad

  • Query designing problem while applying cell properties

    Hello Experts,
    I have a problem while designing query. Problem is as follow:
    I have a calculated field on key figure column. This key figure calculates variance between 2 columns.
    for E.g I have 2 columns Budget and Actual and third column is %Variance which should be          
    1. ((Actual - Budget)/Budget) *100 or
    2. ((Budget -Actual)/Budget)*100, depening on some values on the row i should use any of these 2 formulas but the result should be dispalyed in single column % Variance.
    how can i change the formula in key figures depending on these conditions. I can achieve this by applying cells but i dont want to do so as it is very complex way to desing these queries.
    also let me know applying cells on query affects its performance or not?
    Regards,
    Nirav

    Hi Nitin,
    Your reply may help me.
    But my exact requirement is not that. Requirement is as follow:
    I have created Char. Structure in row which contains few rows as revenue and few rows as expense.
    I created them by creating selections. Now in case of expense the variance should be                (Budget-Actual)/Budget *100.
    In case of revenue variance should be (Actual-Budget)/Budget *100.
    So, here i have to find out revenue & expense char. iresspective of which one is greater.
    Regards,
    Nirav

  • Query has problem

    Below query has problem .
    Pls see the queries for Usage Summary with Partition and Without Partition
    . I have executed this now so it may be in Buffer …****
    DB Query ... SUM from event objects, bin variables
    SELECT sum(amount) , sum(quantity), event.poid_type,ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,ebal.
    rate_obj_id0, ebal.OFFERING_OBJ_ID0, ebal.IMPACT_CATEGORY ****
    FROM event_bal_impacts_t ebal, item_t item, event_tevent*
    WHERE event.item_obj_id0 = item.poid_id0****
    AND ebal.obj_id0 = event.poid_id0****
    --                   and event.Poid_id0 >= 266838277921701888****
    --                 and event.Poid_id0 < 267928993456455680****
    --               and ebal.obj_id0 >= 266838277921701888****
    --             and ebal.obj_id0 < 267928993456455680****
    AND item.bill_obj_id0 = 148715294****
    AND ebal.product_obj_id0 = 27433706****
    AND ebal.account_obj_id0 = 146876519****
    AND item.account_obj_id0 = 146876519****
    AND event.poid_type like '%session/telco/gsm%'****
    AND ebal.impact_category <> 'Free'****
    AND resource_id not in (select resource_id from
    resource_id_t)****
    group by****
    event.poid_type, ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,****
    ebal.rate_obj_id0, ebal.OFFERING_OBJ_ID0,ebal.
    IMPACT_CATEGORY****
    order by****
    ebal.resource_id desc;****
    SELECT sum(amount) , sum(quantity), event.poid_type,ebal.
    resource_id,****
    event.service_obj_type, event.service_obj_id0,ebal.
    rate_obj_id0, ebal.OFFERING_OBJ_ID0, ebal.IMPACT_CATEGORY ****
    FROM event_bal_impacts_t ebal, item_t item, event_tevent*
    WHERE event.item_obj_id0 = item.poid_id0****
    AND ebal.obj_id0 = event.poid_id0****
    and event.Poid_id0 >= 264199450015039488****
    and event.Poid_id0 < 265237388991660032****
    and ebal.obj_id0 >= 264199450015039488****
    and ebal.obj_id0 < 265237388991660032****
    AND item.bill_obj_id0 = 148715294****
    AND ebal.product_obj_id0 = 27433706****
    AND ebal.account_obj_id0 = 146876519****
    AND item.account_obj_id0 = 146876519****
    AND event.poid_type like '%session/telco/gsm%'****
    AND ebal.impact_category <> 'Free'****
    AND resource_id not in (select resource_id from
    resource_id_t)****
    group by****
    event.poid_type, ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,****
    ebal.rate_obj_id0, ebal.OFFERING_OBJ_ID0,ebal.
    IMPACT_CATEGORY****
    order by****
    ebal.resource_id desc;****
    --

    848478 wrote:
    Below query has problem .
    Pls see the queries for Usage Summary with Partition and Without Partition
    . I have executed this now so it may be in Buffer …****
    DB Query ... SUM from event objects, bin variables
    SELECT sum(amount) , sum(quantity), event.poid_type,ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,ebal.
    rate_obj_id0, ebal.OFFERING_OBJ_ID0, ebal.IMPACT_CATEGORY ****
    FROM event_bal_impacts_t ebal, item_t item, event_tevent*
    WHERE event.item_obj_id0 = item.poid_id0****
    AND ebal.obj_id0 = event.poid_id0****
    --                   and event.Poid_id0 >= 266838277921701888****
    --                 and event.Poid_id0 < 267928993456455680****
    --               and ebal.obj_id0 >= 266838277921701888****
    --             and ebal.obj_id0 < 267928993456455680****
    AND item.bill_obj_id0 = 148715294****
    AND ebal.product_obj_id0 = 27433706****
    AND ebal.account_obj_id0 = 146876519****
    AND item.account_obj_id0 = 146876519****
    AND event.poid_type like '%session/telco/gsm%'****
    AND ebal.impact_category <> 'Free'****
    AND resource_id not in (select resource_id from
    resource_id_t)****
    group by****
    event.poid_type, ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,****
    ebal.rate_obj_id0, ebal.OFFERING_OBJ_ID0,ebal.
    IMPACT_CATEGORY****
    order by****
    ebal.resource_id desc;****
    SELECT sum(amount) , sum(quantity), event.poid_type,ebal.
    resource_id,****
    event.service_obj_type, event.service_obj_id0,ebal.
    rate_obj_id0, ebal.OFFERING_OBJ_ID0, ebal.IMPACT_CATEGORY ****
    FROM event_bal_impacts_t ebal, item_t item, event_tevent*
    WHERE event.item_obj_id0 = item.poid_id0****
    AND ebal.obj_id0 = event.poid_id0****
    and event.Poid_id0 >= 264199450015039488****
    and event.Poid_id0 < 265237388991660032****
    and ebal.obj_id0 >= 264199450015039488****
    and ebal.obj_id0 < 265237388991660032****
    AND item.bill_obj_id0 = 148715294****
    AND ebal.product_obj_id0 = 27433706****
    AND ebal.account_obj_id0 = 146876519****
    AND item.account_obj_id0 = 146876519****
    AND event.poid_type like '%session/telco/gsm%'****
    AND ebal.impact_category <> 'Free'****
    AND resource_id not in (select resource_id from
    resource_id_t)****
    group by****
    event.poid_type, ebal.resource_id,****
    event.service_obj_type, event.service_obj_id0,****
    ebal.rate_obj_id0, ebal.OFFERING_OBJ_ID0,ebal.
    IMPACT_CATEGORY****
    order by****
    ebal.resource_id desc;****
    --Consider getting the asterisk key fixed, since it results in invalid SQL syntax

  • Failure to search - query window problem

    Hello again,
    Have anyone of you came across a problem with SAP search mechanism in query window attached to document field? I've created a simple query of "Select acctcode,acctname from OACT where acctcode like '2%' and postable='Y' order by acctcode" and attached it to one of document fields (doesn't matter which one). When I run this query a usual window poped up with a search field on the top, but when I typed "2" in it, selection bar moved right into first 231 account ignoring any of the lesser numbers. There is more - when I changed query to search for '5%' like accounts, I gained the same result - accounts less than 530 were ignored even if I typed "50" or "51". BUT - when I changed query sort order to "desc", all account became "findable".
    I got this problem in one database only which is SAP 8.8 PL10 version upgraded recently from 2007A one. I've checked with a newly created 8.8 and such problem hasn't occured.

    Hello Thomasz,
    I might be off base here, what happens when you use this??? 
    Do you get the same types of query window problem???
    Select
    acctcode,
    acctname,
    segment_0
    from OACT
    where Segment_0 like '2%'
    order by acctcode
    for browse
    Regards,
    Zal

  • Query tunning in RAC system

    Hi,
    I have a RACsystem with 2 nodes (oracle 10.2.0.1.0, Linux RedHat 4)
    I have a simple query that take a long time but in the same server with a single database it's fast!!??
    here is the query:
    select count(*) as y0_, this_.NOTIFICATION_TYPE as y1_
    from NOTIFICATION this_
    where this_.OPCO_ID=1
    and this_.SENTDATE is null
    and this_.UPDATED_TIME is null
    and this_.CREATED_TIME>=sysdate
    and this_.CREATED_TIME<=sysdate
    group by this_.NOTIFICATION_TYPE
    order by this_.NOTIFICATION_TYPE asc
    With AWR I can see that I lost a long time in gc_buffer_busy_wait!!
    NB:I have a blob in my table
    How I can solve my problem?
    Message was edited by:
    vittel

    You have hit one of the many features of RAC. On a single instance database a piece of data is either in its SGA in local memory, or out on disk. On a multi-instance RAC database a piece of data can now either be in the local SGA memory, or the remote SGA memory of the other node, or out on disk.
    Given that Oracle assumes that it is quicker to go across the network interconnect between the 2 RAC nodes to retrieve the copy of the data from the other SGA than it is to go all the way out to disk to read that data page, Oracle RAC is biased to using copies of data blocks in the SGAs of the other RAC nodes.
    You cannot stop this. Oracle RAC is doing as it is intended to. Either tune and improve the performance of the interconnect between your 2 nodes. Are you using 100 baseT or 1000 baseT or something even faster? It is the latency that is the issue, not the bandwidth.
    Or stop using RAC, and go back to just one database instance.
    John

  • Mythbackend and hauppage USB tuner problems

    I'm coming from using ubuntu for the last year and I've switched over to arch around a month ago. Everything on my server is running nicely and I've learnt more about Linux in the last few weeks than I did in a year of ubuntu, but I've got one last little problem I can't wrap my head around.
    Please bear with me because I'm no where near my pc ( and won't be untill the weekend, but I've got remote ssh access to it if needs be )
    with ubuntu I've been using a hauppage wintv nova T500 pci and a wintv USB stick. The pci card mounts itself as 2 USB tuners. I've loaded the firmware for the tuners (they both use the same firmware) and they show up when I check lsusb and dmesg.
    I've tried mythtv from the repo and mythtv .22 built from the aur, both are giving me the same problem.
    Mythbackend is loaded as a daemon in my rc.conf file and it loads fine but then errors out as it can't find any tuners.  the only way I can get myth to work is to unplug the USB tuner and pci card, remove mythbackend from my daemons and when I start the pc up plug the USB tuner in after I get to the command prompt then manually start mythbackend. This way it works fine everytime but I can't use the pci tuner as I don't fancy plugging that in while the pc's on
    any help would be Appreciated as it's driving me nuts, I can grab any logfiles anyones after once I finish work (posting this from my phone at work)

    the output from that is:
    usbcore: registered new interface driver dvb_usb_dib0700
    dvb-usb: found a 'Hauppauge Nova-T Stick' in cold state, will try to load a firmware
    usb 1-3: firmware: requesting dvb-usb-dib0700-1.20.fw
    dvb-usb: downloading firmware from file 'dvb-usb-dib0700-1.20.fw'
    dvb-usb: found a 'Hauppauge Nova-T Stick' in warm state.
    dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
    dvb-usb: schedule remote query interval to 50 msecs.
    dvb-usb: Hauppauge Nova-T Stick successfully initialized and connected.
    Modules linked in: cpufreq_userspace rfcomm sco bridge stp llc bnep l2cap it87 hwmon_vid ipv6 ext2 btusb bluetooth rfkill joydev hid_sunplus usbhid hid fan battery ac snd_hda_codec_realtek powernow_k8 freq_table snd_seq_dummy snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device snd_pcm_oss snd_mixer_oss snd_hda_intel fuse dvb_usb_dib0700 snd_hda_codec snd_hwdep snd_pcm snd_timer ohci_hcd dib7000p snd ehci_hcd dib7000m dvb_usb mt2266 tuner_xc2028 dib3000mc dibx000_common mxl5007t xc5000 s5h1411 mt2060 parport_pc ppdev lgdt3305 nvidia(P) lp thermal parport psmouse pcspkr i2c_piix4 serio_raw button processor agpgart usbcore r8169 miisoundcore snd_page_alloc dvb_core dib0070 wmi sg evdev i2c_core rtc_cmos rtc_core rtc_lib ext4 mbcache jbd2 crc16 sd_mod pata_acpi pata_atiixp ahci ata_generic libata scsi_mod
    thats just the usb tuner plugged in, i took the pci one out before i left for the week.
    to me it looks as if its registered properly and everythings fired in. But like i said im new to Arch and i was kinda used to just plugging stuff into ubunutu and it automagically working

  • Using substr function loses index. Query tune help

    Hi
    when i use substr function in the join condition it loses index and the query is slow. How to fix this problem or tune this query. These are the lines in the query.
    and substr(a.invoice_num,1,9) = l.invoice_num
    and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
    and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key
    select
    pap.full_name employe_name,
         k.SEGMENT1 ||'.' ||k.segment2 Cost_Center,
         a.invoice_num Invoice_Number,
         b.item_description Line_Item,
         b.amount Amount,
         cc.trx_id Corporate_Card_Transaction_Id,
         cc.transaction_date Date_Charge_Incurred,
         cc.posted_date Date_Charge_Posted_To_USBank,
         cc.creation_date Date_Posted_To_IExpense,
         a.creation_date Expense_Report_Creation_Date,
         l.report_submitted_date Expense_Report_Submitted_Date,
         mgr_apprv_lst.activity_begin_date Managers_Approval_Begin_Date,
         mgr_apprv_lst.activity_end_date Managers_Approval_End_Date,
         pbl_apprv_lst.activity_begin_date AP_Approval_Begin_Date,
         pbl_apprv_lst.activity_end_date AP_Approval_End_Date,
         e.check_date Payment_Date_To_USBank,
         e.check_number Payment_Number,
         mgr_apprv_lst.activity_result_display_name Managers_Process_Result,
         pbl_apprv_lst.activity_result_display_name AP_Process_Result
    from
         ap_checks_all e,
         ap_invoice_payments_all d,
         ap_invoices_all c,
    ap_expense_report_headers_all a,
         ap_credit_card_trxns_all cc,
         per_all_people_f pap,
         ap_expense_report_headers_all l,
         ap_expense_report_lines_all b,
         gl_code_combinations k,
         (select ias1.user_key,
         ias1.activity_result_display_name,
         ias1.activity_begin_date,
         ias1.activity_end_date
    from wf_item_activity_statuses_v ias1,
    (select c1.invoice_num
         from ap_checks_all e1,
         ap_invoice_payments_all d1,
         ap_invoices_all c1
         where trunc(e1.check_date) between nvl(:From_Date, trunc(e1.check_date))
         and nvl(:To_Date, trunc(e1.check_date))
    and e1.org_id = 141
    and e1.void_date IS null
    and d1.check_id = e1.check_id
         and c1.invoice_id = d1.invoice_id) inv_lst1
    where ias1.item_type = 'APEXP'
    and ias1.user_key = inv_lst1.invoice_num
    and ias1.activity_name = 'AP_MANAGER_APPROVAL_PROCESS') mgr_apprv_lst,
    (select ias2.user_key,
         ias2.activity_result_display_name,
         ias2.activity_begin_date,
         ias2.activity_end_date
    from wf_item_activity_statuses_v ias2,
    (select c2.invoice_num
         from ap_checks_all e2,
         ap_invoice_payments_all d2,
         ap_invoices_all c2
         where trunc(e2.check_date) between nvl(:From_Date, trunc(e2.check_date))
         and nvl(:To_Date, trunc(e2.check_date))
    and e2.org_id = 141
    and e2.void_date IS null
    and d2.check_id = e2.check_id
         and c2.invoice_id = d2.invoice_id) inv_lst2
    where ias2.item_type = 'APEXP'
    and ias2.user_key = inv_lst2.invoice_num
    and ias2.activity_name = 'AP_PAYABLES_APPROVAL_PROCESS') pbl_apprv_lst
    where
    trunc(e.check_date) between nvl(:From_Date, trunc(e.check_date))
    and nvl(:To_Date, trunc(e.check_date))
    and e.org_id = 141
    and e.void_date IS null
    and d.check_id = e.check_id
    and c.invoice_id = d.invoice_id
    and a.invoice_num = c.invoice_num
    and a.source = 'CREDIT CARD'
    and a.employee_id = nvl(:Emp_id,a.employee_id)
    and a.report_header_id = b.report_header_id
    and cc.trx_id = b.credit_card_trx_id
    and pap.person_id = a.employee_id
    and pap.effective_start_date <= trunc(sysdate)
    and pap.effective_end_date >= trunc(sysdate)
    and k.code_combination_id = b.code_combination_id
    and k.segment2 between nvl(:From_Cost_Center,k.segment2)
    and nvl(:To_Cost_Center,k.segment2)
    and substr(a.invoice_num,1,9) = l.invoice_num
    and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
    and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key

    Hi
    If I understood correctly your logic, and if the columns involved are of type varchar2, you can use the like operator:
    and a.invoice_num like l.invoice_num || '%'
    and c.invoice_num like mgr_apprv_lst.user_key  || '%'
    and c.invoice_num like pbl_apprv_lst.user_key  || '%'In this case, Oracle will be able to use the indexes. If they are numeric, you need to do something like:
    and a.invoice_num between l.invoice_num * 1000000
                                and l.invoice_num * 1000000 + 999999I hope this makes sense...
    Luis

  • Tv tuner problem!!!!  this is urgent please help....

    Hi,
    I'm trying to capture vidfeo from tv tuner I've done it before with several kinds of tuners
    I'm using " Ati All In Wonder 128 " -display adapter with tv tuner- now and it is giving strange colors on JMF
    studio although it runs fine on Ati software
    any help will be good even any wild guesses will be helpful
    duke

    thanks for your reply
    this problem is fixed now after I captured another format UYVY instead of YUV
    but there is a nother problem if capture with 16 pits per pixel the screen is fine but with 24 a thick black line is at the top of the screen
    the problem is I can change the pits per pixel parameter in jmf studio
    but in my code
    I query the CaptureDeviceManager with a VideoFormat object (it has no way to set the pits per pixel)
    and it is giving the black line
    and when I try to query the CaptureDeviceManager with RGBFormat object to set teh pits per pixel
    It returns a 0 length array of capture device info
    are you familiar with such a problem
    thanks in advance

  • Query help - problems with ROLLUP

    I'm trying to make a query i can use for an alert, it generates sales for the past 7 days.
    This query works fine:
    SELECT
          CASE WHEN GROUPING(T0.[CardCode]) = 0
                THEN CAST (T0.[CardCode] AS CHAR(8))
                ELSE 'ALL'
          END AS Customer#,
          SUM(T0.[Max1099]) AS "Total Sales",
          SUM(T0.[GrosProfit]) AS "Gross Profit" 
    FROM OINV T0
    WHERE T0.[DocDate] >= DATEADD(dd,DATEDIFF(dd,0,GETDATE())-7,0) AND T0.[Max1099] > 0
    GROUP BY T0.[CardCode] WITH ROLLUP
    And it gives me this:
    #     Customer#*     Total Sales*     Gross Profit*     
    1     C2235              8,285.87       4,165.77            
    2     C2236           10,191.39              4,197.95            
    3     C2253                570.56               311.17          
    4     C3008           18,756.76       5,720.21            
    5     ALL                   37,804.58    14,395.10            
    Which is great. Gives me a total at the end, and substitutes "ALL" for the customer number. Lovely.
    Problem #1: I REALLY want it to give the Customer Name NEXT TO the Customer Number. But when I try to add it, i have to add it to the GROUP BY as well. Which changes the query to this:
    SELECT
          CASE WHEN GROUPING(T0.[CardCode]) = 0
                THEN CAST (T0.[CardCode] AS CHAR(8))
                ELSE 'ALL'
          END AS Customer#,    
          CardName as "Cust Name",     
          SUM(T0.[Max1099]) AS "Total Sales",
          SUM(T0.[GrosProfit]) AS "Gross Profit"
    FROM OINV T0
    WHERE T0.[DocDate] >= DATEADD(dd,DATEDIFF(dd,0,GETDATE())-7,0) AND T0.[Max1099] > 0
    GROUP BY T0.[CardCode], T0.[CardName] WITH ROLLUP
    And changes my output to THIS:
    #     Customer#     Cust Name                             Total Sales     Gross Profit     
    1     C2235             Acme Products                      8,285.87               4,165.77     
    2     C2235          (blanks blanks)                        8,285.87               4,165.77     
    3     C2236             Some Other Products             10,191.39               4,197.95     
    4     C2236          (blanks blanks blanks)            10,191.39               4,197.95     
    5     C2253             Third Customer Name             570.56                  311.17     
    6     C2253          (blanks blanks blanks)                570.56                  311.17     
    7     C3008             Fourth Customer Name       18,756.76       5,720.21     
    8     C3008          (blanks blanks blanks)                                               18,756.76       5,720.21     
    9     ALL                                                                  37,804.58     14,395.10     
    ( I have replaced actual customer names, of course, and replaces actual blanks with the word 'blanks' so it would be more legible.)
    I can't figure out a way to simply list the customer name next to the number. Instead , it gives me a summary for the CardCode and a summary for the CardName.
    I've tried combining the two into one field, on the fly, but haven't been successful.
    Problem #2 - extra credit!
    If i really want this done right, i should also have a query that pulls the same data from ORIN (Credit Memos) and do a UNION ALL, but when i do this, is simply rejects me at the word "UNION"
    any and all help appreciated, and to test this, you can just cut and past the query into SAP, it will run right there, no mods needed.
    oops. I had to change the "Not Equal" symbol to just "greater than" for "Max1099" because it was just dropping the symbol...
    Edited by: Dante Amodeo on Jan 18, 2012 6:30 PM

    Try:
    SELECT CAST (T0.CardCode AS CHAR(8)) AS Customer#,
    MAX(T0.CardName) 'Customer Name',
    SUM(T0.Max1099) AS 'Total Sales',
    SUM(T0.GrosProfit) AS 'Gross Profit'
    FROM OINV T0
    WHERE DATEDIFF(dd,T0.DocDate,GETDATE())<=7 AND T0.Max1099 > 0
    GROUP BY T0.CardCode
    UNION ALL
    SELECT 'ALL','',SUM(T0.Max1099),
    SUM(T0.GrosProfit)
    FROM OINV T0
    WHERE DATEDIFF(dd,T0.DocDate,GETDATE())<=7 AND T0.Max1099 > 0

  • BI 7.0 Infoset query open problem: query_tech_name_Fxx is not a valid char.

    Our BASIS transport our BW 3.5 queries to BI 7.0 system.  We can open all queries on the BI 7.0 box without problem except Infoset queries.  The Infoset is composed of two ODSs and when openning it BI 7.0 query designer, can not see any design element in the panes of Rows, Columns, Free Char. and etc., instead the error msg shows (in between two dashed lines below):
    Terminate: query_technical_name_Fxx is not a valid characteristic for InfoProvider [A122(BRAIN)]
    Diagnosis
    Customer enhancement RSR00002 or the implementation of BAdI RSR_OLAB_BADI delivers query_technical_name_Fxx as the characteristic to be calculated. 1. is, however, not a valid key figure for InfoProvider .
    System Response
    The information from query_technical_name_Fxx is ignored.
    Procedure
    Check the exit.
    Procedure for System Administration
    We've checked the enhancement RSR00002 and it's components and find they are all the same as our BW 3.5 system.  query_technical_name_Fxx is Company Code InfoObj. in one ODS and it's one of the key to join these two InfoSets.
    Any idea?
    Thanks

    hi Kevin,
    check if helps following oss note
    Note 983449 - Termin A122 1COLUMN no valid characteristic of infoprovider
    Symptom
    Termination A 122 Brain occurs when you test and generate a query. The system does not recognise the characteristic 1COLUMN.
    Other terms
    Query, condition, COB_PRO
    Reason and Prerequisites
    This problem is caused by a program error.
    Solution
    SAP NetWeaver 2004s BI
               Import Support Package 10 for SAP NetWeaver 2004s BI (BI Patch 10 or SAPKW70010) into your BI system. The Support Package is available once Note 914304 "SAPBINews BI 7.0 Support Package 10", which describes this Support Package in more detail, has been released for customers.
    In urgent cases, you can implement the correction instructions.
    You must first implement Notes 932065, 935140, 948389, 964580 and 969846, which provide information about transaction SNOTE. Otherwise, problems and syntax errors may occur when you deimplement some notes.

  • The problem about  integrate  Portal and R/3 : vendor query report problem

    Hi everyone :
       We want to achieve that our vendor can query R/3 report via our Portal. I had done SSO configuration.
       But we had about 500 vendors, it is impossible that we create 500 R/3 users for our vendors,  because the cost is too much .
       And there is another problem, vendor who had the authorization to query report can query the other vendor's data at same time. But we expect that certain vendor can query his data only.
       I think this is a general problem when integrate Portal and R/3, BW .
       Is there somebody had solved this problem or give any advice?
       Any discuss is welcome.
    Best Regards,
    Jianguo Chen

    Hi,
    I would say: get in contact with your SAP account manager anc check which options SAP can offer you...
    Normally every user using a R/3 system has to have a valid user license in that system. Expecially when you want to access control to data on user (vendor) level you nedd to identifiy the user clearly and uniquely which by standard means you need a user for every vendor.
    Hth,
    Michael

  • HELP - Query Join Problem

    I am trying to write a query to return data from 4 different tables and it is doubling my summed values. I can get the separate queries to work, but not combined and I need them combined so that I can get a balance due and limit the records to only those that had a total billed (fees) less than $200.
    Query #1 Gets the total of the fees due for each appeal type and invoice:
    Note: There is always at least one fee attached to an invoice.
    SELECT APT.APTY_DESCR "APPEAL TYPE",
    INV.INVC_ID_SEQ INVOICE,
    SUM( ALL FEE.AMT_DUE) "TOTAL BILLED AMOUNT"
    FROM WRD_APPEALS AP,
    WRD_INVOICES INV,
    WRD_FEES_DUE FEE,
    WRD_APPEAL_TYPES APT
    WHERE AP.APST_CD = 'PEND'
    AND AP.INVC_ID_SEQ = INV.INVC_ID_SEQ
    AND AP.INVC_ID_SEQ = FEE.INVC_ID_SEQ
    AND AP.APTY_CD = APT.APTY_CD
    GROUP BY APT.APTY_DESCR, INV.INVC_ID_SEQ
    ORDER BY APT.APTY_DESCR, INV.INVC_ID_SEQ
    4     BILLING CATEGORY INCORRECT     4147     1200
    5     BILLING CATEGORY INCORRECT     4203     1100
    6     BILLING CATEGORY INCORRECT     4216     72600
    7     BILLING CATEGORY INCORRECT     4826     1000
    8     BILLING CATEGORY INCORRECT     4951     2060
    Query #2 Gets the total amount paid for each appeal type and invoice:
    Note: An invoice may or may not have a payment, thus the outer join.
    SELECT APT.APTY_DESCR "APPEAL TYPE",
    INV.INVC_ID_SEQ INVOICE,
    SUM(ALL PMT.PAID_AMT) "AMOUNT PAID"
    FROM WRD_APPEALS AP,
    WRD_INVOICES INV,
    WRD_APPEAL_TYPES APT,
    WRD_PAYMENTS PMT
    WHERE AP.APST_CD = 'PEND'
    AND AP.INVC_ID_SEQ = INV.INVC_ID_SEQ
    AND AP.APTY_CD = APT.APTY_CD
    AND INV.INVC_ID_SEQ = PMT.INVC_ID_SEQ(+)
    GROUP BY APT.APTY_DESCR, INV.INVC_ID_SEQ
    ORDER BY APT.APTY_DESCR, INV.INVC_ID_SEQ
    4     BILLING CATEGORY INCORRECT     4147     200
    5     BILLING CATEGORY INCORRECT     4203     0
    6     BILLING CATEGORY INCORRECT     4216     72600
    7     BILLING CATEGORY INCORRECT     4826     
    8     BILLING CATEGORY INCORRECT     4951     
    Combined Query - Gets all of the above as well as the balance due. Note the doubled values for some records.
    SELECT APT.APTY_DESCR "APPEAL TYPE",
    INV.INVC_ID_SEQ INVOICE,
    SUM( ALL FEE.AMT_DUE) "TOTAL BILLED AMOUNT",
         SUM(ALL PMT.PAID_AMT) "AMOUNT PAID",
         (SUM(ALL FEE.AMT_DUE) -
         NVL2(SUM(ALL PMT.PAID_AMT), SUM(ALL PMT.PAID_AMT), 0)) "BALANCE DUE"
    FROM WRD_APPEALS AP,
    WRD_INVOICES INV,
    WRD_FEES_DUE FEE,
    WRD_APPEAL_TYPES APT,
         WRD_PAYMENTS PMT
    WHERE AP.APST_CD = 'PEND'
    AND AP.INVC_ID_SEQ = INV.INVC_ID_SEQ
         AND INV.INVC_ID_SEQ = PMT.INVC_ID_SEQ(+)
         AND INV.INVC_ID_SEQ = FEE.INVC_ID_SEQ
         AND AP.APTY_CD = APT.APTY_CD
    GROUP BY APT.APTY_DESCR, INV.INVC_ID_SEQ
    ORDER BY APT.APTY_DESCR, INV.INVC_ID_SEQ,
    4     BILLING CATEGORY INCORRECT     4147     1200     400     800
    5     BILLING CATEGORY INCORRECT     4203     2200     0     2200
    6     BILLING CATEGORY INCORRECT     4216     72600     435600     -363000
    7     BILLING CATEGORY INCORRECT     4826     1000          1000
    8     BILLING CATEGORY INCORRECT     4951     2060          2060
    HELP PLEASE!
    Thank you.

    When you have multiple child rows, the parent row gets returned once for each child row found. Therefore, if you have summed the invoice, it gets summed again for each payment. Perhaps this little example will help you understand the problem.
    Note that I used a sub query here to obtain the desired results. Analytic functions can do the same I believe, but I am still learning them :-)
      D> DROP TABLE DMILL.invoice;
    Table dropped.
      D>
      D> DROP TABLE DMILL.payments;
    Table dropped.
      D>
      D> CREATE TABLE invoice AS
         SELECT 1 id, 10 amount FROM DUAL UNION ALL
         SELECT 2 id, 10  FROM DUAL UNION ALL
         SELECT 2 id, 10  FROM DUAL UNION ALL
         SELECT 3 id, 10  FROM DUAL;
    Table created.
      D>
      D> CREATE TABLE payments AS
         SELECT 1 inv_id, 5 amount FROM DUAL UNION ALL
         SELECT 1 inv_id, 5 amount FROM DUAL UNION ALL
         SELECT 2 inv_id, 5 amount FROM DUAL UNION ALL
         SELECT 2 inv_id, 5 amount FROM DUAL UNION ALL
         SELECT 2 inv_id, 5 amount FROM DUAL;
    Table created.
      D>
      D> select * from invoice;
            ID     AMOUNT
             1         10
             2         10
             2         10
             3         10
      D>
      D> select * from payments;
        INV_ID     AMOUNT
             1          5
             1          5
             2          5
             2          5
             2          5
      D>
      D> select id
                  ,sum (amount)
          from  invoice
         group by id;
            ID SUM(AMOUNT)
             1          10
             2          20
             3          10
      D>
      D> select inv_id
                  ,sum(amount)
          from  payments
         group by inv_id;
        INV_ID SUM(AMOUNT)
             1          10
             2          15
      D>
      D> select inv.id
                  ,inv.amount
                  ,pay.amount
          from invoice  inv
                 ,payments pay
         where pay.inv_id = inv.id;
            ID     AMOUNT     AMOUNT
             1         10          5
             1         10          5
             2         10          5
             2         10          5
             2         10          5
             2         10          5
             2         10          5
             2         10          5
    8 rows selected.
      D>
      D> select inv.id
                  ,sum(inv.amount)
                  ,sum(pay.amount)
          from invoice  inv
                 ,payments pay
         where pay.inv_id = inv.id
         group by inv.id;
            ID SUM(INV.AMOUNT) SUM(PAY.AMOUNT)
             1              20              10
             2              60              30
      D>
      D> select inv.id
                  ,sum(inv.amount)
                  ,(SELECT sum(pay.amount)
                    FROM   payments pay
                    WHERE  pay.inv_id = inv.id)
          from invoice  inv
         group by inv.id;
            ID SUM(INV.AMOUNT) (SELECTSUM(PAY.AMOUNT)FROMPAYMENTSPAYWHEREPAY.INV_ID=INV.ID)
             1              10                                                           10
             2              20                                                           15
             3              10Let me know if you need further explanation.

  • Report query parsing problem

    I didn't find any report of this problem...
    Using APEX 3.0.1.00.07, I have a report of type "SQL Query (PL/SQL function body returning SQL query)" with the "Use Generic Column Names (parse query at runtime only)" radio button selected.
    When the region source contains the string "ORDER BY" in any form that I've tried (even in a comment), attempting to save the region fails with "Your query can't include an "ORDER BY" clause when having column heading sorting enabled."
    I do indeed have column sorting enabled on certain columns, but I don't see how that is relevant under these circumstances since the query produced at runtime does not have an ORDER BY clause.
    Am I overlooking something or is this a parsing problem?
    Rodney

    Rodney,
    It's just checking for order by being included in your query, and if so and you have column heading sorting enabled, it's raising this error because you can't have both (even if it's commented out).
    Regards,
    Marc

Maybe you are looking for

  • Extending 0BP_DEF_ADDRESS_ATTR to Extract Mobile Phone number

    I'm currently attempting to extend the 0BP_DEF_ADDRESS_ATTR to include the business partners mobile number. We have appended a "Z" field to the extract structure & are now trying to fill it from table ADR2, where r3_user = 3 If anyone has already don

  • Access  error

    When I attempt to convert a PDF file to Word using Export PDF, I receive an error message "An error occurred while trying to access the service".  No other words or hints as to the cause are offered.  My subscription to Export PDF is current and ther

  • SQL-Only Many-to-Many View Links?

    Hi, ADF, BC4J, Jdeveloper 10.1.3 I am working on a reporting system that contains a number of reports on tables that are linked with many-to-many relationships. So for example, I have a COMPANIES table that is linked through an intermediate table to

  • Create Sales Organization for BP in ICWC

    Hi there, my problem is the following: I inserted the BP value into the Identification Account of ICWC. Now, If I go into the interaction record ti asks me the BP Sales Organization with an error message. How can I create it in order to avoid the err

  • Fly mode problem

    I activated the fly mode and then restarted the phone. It seems to freeze at startup after SONY logo. Black screen remains for over 5 minutes so I have to restart the phone with red button, then it works again. Generally boot take long times, I hope