Query Fomula problem

Hi all,
we have a query that include Fiscal/year period and Amount in it.
For example,Input 2008001 and 2009001,I want to calculate  the gap amount between two Fiscal/year
period.
Moveover,the format is below:
                  2008001   2009001  Gap
Cost center   1000$       2000$   1000$
I don't know how to add Gap field to report,please help me.

Dear both,
Thanks for your reply.
I have try this way,but there may be a problem.
Create two Restricted key figures RKF1 and RKF2.
RKF1 = amount restricted to fiscal year 2008001
RKF2 = amount restricted to fiscal year 2009001
I also add the variant in both restricted key figures,the result of report didn't show the input fiscal year
period(like 2008001,2009001) instead with the name of Restricted key figures(Like RKF1 and RKF2).But
i really need the variant input dynamic to compare the fiscal year period amount(Like User can input
2008001,2009001 or 2008002,2009002).
Regards,
James.

Similar Messages

  • 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 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

  • BEx query change problem

    Hi there,
    In QA, when I try to open the local view or global view of a query in BEx, I am getting the following error/message
    "The following objects were not found when accessing the server.."
    -Press Repair to correct the problem(incorrect parts of the query are automatically deleted)
    If anyone has faced the issue kindly let me know.
    Thank You
    Ace

    Hi Ace,
    Welcome to SDN!
    It seems the objects mentioned in the message were not available in the dataprovider on which the query is based, hence the query designer is trying to correct this (which is a default behavior of the query designer).
    This can happen if you had those objects in the datatarget initially and both the datatarget/query were transported into QA initially, and subsequently any of those objects may have been removed from the datatarget definition, and when the latest objects are moved to QA, by default query designer detects it and prompts you for the correction.
    So, after validating the fact that those missing objects were removed for valid reasons from the corresponding datatarget definition, click on repair and you should be able to continue further.
    Hope it helps,
    Sree

  • Select query join problem

    hey guys,
    i've used a select query to get details from KNA1, KNVV, ADRC, KNVP, pa0002. tables by joining. but i'm getting only about 170 records. there are more than 3000 records in the database. for each tables. here is my select query
    SELECT KNA1KUNNR KNA1NAME1 KNA1NAME2 ADRCSTR_SUPPL1 ADRCSTR_SUPPL2 ADRCSTR_SUPPL3 ADRCCITY1 KNVVVWERK KNVPPERNR PA0002VORNA PA0002NACHN KNVVVKBUR KNVVKDGRP KNA1STCD1 KNA1~STCEG
        INTO CORRESPONDING FIELDS OF TABLE IT_FINAL FROM KNA1
        INNER JOIN KNVV ON KNA1KUNNR = KNVVKUNNR
        INNER JOIN ADRC ON KNA1ADRNR = ADRCADDRNUMBER
        INNER JOIN KNVP ON KNA1KUNNR = KNVPKUNNR
        INNER JOIN PA0002 ON KNVPPERNR = PA0002PERNR
        WHERE KNA1KUNNR IN S_KUNNR AND KNVVVWERK in P_VWERK AND PA0002PERNR IN S_PERNR AND KNVVVKBUR IN S_VKBUR AND KNVV~KDGRP IN S_KDGRP.
    can anyone tell me the problem in the above query.
    thanks.

    Hi
    you are using tables KNA1, KNVV, ADRC, KNVP, pa0002.
    Create internal table for each table mentioned above with all the primary keys and find the links between them
    then select data in one table and select data from another table into your internal table for all the entries exists in firs internal table.
    go for below links.
    http://www.sapdev.co.uk/abap/commands/select_forallentries.htm
    http://wiki.sdn.sap.com/wiki/display/ABAP/FORALLENTRIES-Home+page
    http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_ITAB.htm
    Thanks
    lalit

  • Query designer problem

    Dear All,
    I am facing the problem in the query designer that when i edit any of the formula in the query it allows me but when i edit it second time , it wont allow me and throws a following exception...
    "An unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will be shut down immediately.
    Object reference not set to an instance of an object."
    and in details of the exception the following comes...
    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.
                                        Exception Text
    System.NullReferenceException: Object reference not set to an instance of an object.
       at com.sap.bi.et.QueryDesigner.QDbPoolEditSelection.Get()
       at com.sap.bi.et.QueryDesigner.QDbCommandEditElement.EditFormula(IQDView iSelectedView)
       at com.sap.bi.et.QueryDesigner.QDbCommandEditElement.ExecuteCommand()
       at com.sap.bi.et.QueryDesigner.QDbCommandBase.Execute()
       at com.sap.bi.et.QueryDesigner.QDbCommandManager.CommandExecute(QDbCommandBase iCommand)
       at com.sap.bi.et.QueryDesigner.QDbCommandManager.InitialCommandExecute(QDbCommandBase iCommand)
       at com.sap.bi.et.QueryDesigner.QDbCommandManager.DoExecuteCommandInternal()
       at com.sap.bi.et.QueryDesigner.QDbCommandManager.ItemClickedHandler(Object sender, BarItemClickedEventArgs args)
       at com.sap.bi.et.QueryDesigner.QDdEventDispatcher.MenuItemClickedHandler(Object iSender, BarItemClickedEventArgs iE)
       at Syncfusion.Windows.Forms.Tools.XPMenus.BarManager.OnItemClicked(BarItemClickedEventArgs args)
       at Syncfusion.Windows.Forms.Tools.XPMenus.BarItem.OnItemClicked(EventArgs args)
       at com.sap.bi.et.QueryDesigner.QDiBarItem.OnItemClicked(EventArgs args)
       at Syncfusion.Windows.Forms.Tools.XPMenus.BarItem.PerformClick()
       at com.sap.bi.et.QueryDesigner.QDbCommandManager.ExecuteDoubleclickCommand(ParentBarItem iContextMenu)
       at com.sap.bi.et.QueryDesigner.QDbCommandManager.NodeDoubleClickHandler(Object sender, EventArgs e)
       at com.sap.bi.et.QueryDesigner.QDdEventDispatcher.ItemDoubleClickHandler(Object sender, EventArgs e)
       at com.sap.bi.et.QueryDesigner.QDdEventDispatcher.ItemDoubleClickHandler(Object sender, EventArgs e)
       at com.sap.bi.et.QueryDesigner.QDuHeaderTree.OnItemDoubleClick(EventArgs iE)
       at com.sap.bi.et.QueryDesigner.QDuHeaderTree.NodeDoubleClickHandler(Object sender, EventArgs e)
       at System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
       at Syncfusion.Windows.Forms.Tools.TreeViewAdv.OnDoubleClick(EventArgs e)
       at com.sap.bi.et.QueryDesigner.QDiTree.OnDoubleClick(EventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at Syncfusion.Windows.Forms.ScrollControl.WmMouseUp(Message& msg)
       at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg)
       at Syncfusion.Windows.Forms.Tools.TreeViewAdv.WndProc(Message& m)
       at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
                                                     Loaded Assemblies
    mscorlib
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
    BExQueryDesignerStarter
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.486
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExQueryDesignerStarter.exe
    System
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    BExQueryDesigner
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.486
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExQueryDesigner.DLL
    BExCommon
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.122
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExCommon.DLL
    BExControls
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.122
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExControls.DLL
    BExCAControls
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.122
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExCAControls.DLL
    System.Windows.Forms
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2032
        CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
    BExCommunication
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.122
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExCommunication.DLL
    Microsoft.VisualBasic
        Assembly Version: 7.0.5000.0
        Win32 Version: 7.10.6001.4
        CodeBase: file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
    System.Xml
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2032
        CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
    8mfr2iet
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    SAP.Connector
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.0.23
        CodeBase: file:///c:/windows/assembly/gac/sap.connector/2.0.0.0__50436dca5c7f7d23/sap.connector.dll
    Interop.SAPLogonCtrl
        Assembly Version: 1.1.0.0
        Win32 Version: 1.1.0.0
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Interop.SAPLogonCtrl.DLL
    SAP.Connector.Rfc
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.0.23
        CodeBase: file:///c:/windows/assembly/gac/sap.connector.rfc/2.0.0.0__50436dca5c7f7d23/sap.connector.rfc.dll
    BExGeneratedAll
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.123
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExGeneratedAll.DLL
    System.Web.Services
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2032
        CodeBase: file:///c:/windows/assembly/gac/system.web.services/1.0.5000.0__b03f5f7f11d50a3a/system.web.services.dll
    System.Drawing
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2032
        CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
    System.Web
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system.web/1.0.5000.0__b03f5f7f11d50a3a/system.web.dll
    nwibr-hj
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    orv3kyon
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    3wroaodz
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    uzyztof1
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    bmpxtf3w
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    BExControls2
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.123
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExControls2.DLL
    BExSharedImageList
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.122
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExSharedImageList.DLL
    System.Runtime.Serialization.Formatters.Soap
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2032
        CodeBase: file:///c:/windows/assembly/gac/system.runtime.serialization.formatters.soap/1.0.5000.0__b03f5f7f11d50a3a/system.runtime.serialization.formatters.soap.dll
    BExSelectorAPI
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.202
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExSelectorAPI.DLL
    System.Data
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2032
        CodeBase: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
    BExOpenSaveServices
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.108
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExOpenSaveServices.DLL
    Syncfusion.Tools.Windows
        Assembly Version: 4.401.0.51
        Win32 Version: 4.401.0.51
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Syncfusion.Tools.Windows.DLL
    Syncfusion.Shared.Base
        Assembly Version: 4.401.0.51
        Win32 Version: 4.401.0.51
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Syncfusion.Shared.Base.DLL
    Syncfusion.Grid.Windows
        Assembly Version: 4.401.0.51
        Win32 Version: 4.401.0.51
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Syncfusion.Grid.Windows.DLL
    Syncfusion.Core
        Assembly Version: 4.401.0.51
        Win32 Version: 4.401.0.51
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Syncfusion.Core.DLL
    Syncfusion.Grid.Base
        Assembly Version: 4.401.0.51
        Win32 Version: 4.401.0.51
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Syncfusion.Grid.Base.DLL
    Syncfusion.Shared.Windows
        Assembly Version: 4.401.0.51
        Win32 Version: 4.401.0.51
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Syncfusion.Shared.Windows.DLL
    Accessibility
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/windows/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
    AxInterop.SHDocVw
        Assembly Version: 1.1.0.0
        Win32 Version: 1.1.0.0
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/AxInterop.SHDocVw.DLL
    Interop.SHDocVw
        Assembly Version: 1.1.0.0
        Win32 Version: 1.1.0.0
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Interop.SHDocVw.DLL
    Syncfusion.Edit.Windows
        Assembly Version: 4.401.0.51
        Win32 Version: 4.401.0.51
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/Syncfusion.Edit.Windows.DLL
    ezadp-o7
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    czxpebds
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    ws48wlef
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    nbphnkyi
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    qmxat26w
        Assembly Version: 0.0.0.0
        Win32 Version: 1.1.4322.2407
        CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    BExFormulaParser
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.122
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExFormulaParser.DLL
    RegexAssembly140_0
        Assembly Version: 0.0.0.0
        Win32 Version: n/a
        CodeBase:
    System.Design
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.2032
        CodeBase: file:///c:/windows/assembly/gac/system.design/1.0.5000.0__b03f5f7f11d50a3a/system.design.dll
    BExQueryDesignerFormulaParser
        Assembly Version: 7000.0.0.0
        Win32 Version: 7005.5.1401.2
        CodeBase: file:///C:/Program%20Files/SAP/FrontEnd/Bw/BExQueryDesignerFormulaParser.DLL
    JIT Debugging **************
    To enable just in time (JIT) debugging, the config file for this
    application or machine (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    For example:
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the machine
    rather than being handled by this dialog.
    Please anybody help me.
    Nitesh

    Hi,
    This is a typical front end issue where you have to look at your GUI patch and front end patch.I recommend you deinstalling your frontend installation as follows:
    - Remove your frontend via 'START' - 'PROGRAMS' - 'SAP FRONTEND' -
       'REMOVE SAP FRONTEND'
    - Install the newest frontend and GUI patch and check the installation with sapbexc.xla
    Please run the front-end checktool SAPBEXC.XLA as per Note 918394 and ensure there are no errors.
    Path for frontend patches
    Please goto
    -> service.sap.com/patches
    ->entry by application group
    ->SAP Frontend Components
    ->SAP GUI FOR WINDOWS
    ->SAP GUI FOR WINDOWS 6.40
    ->SAP GUI FOR WINDOWS 6.40
    ->Win32
    ->Apply latest frontend patch
    Once the installation is done run the installation check file as per note 918394 and ensure that there are no red flags.
    Rgds
    Manoj Kumar

  • Be query related problem

    hi all
    I AM FACING SIMILAR PROBLEM I.E I CREATED NEW QUERY UNDER ONE CUBE AS PER REQ, AND PREVIOUSLY WHILE I WAS CREATING NEW QUERY IT ASKED FOR NEW REQUEST SO I ASSIGNEd  THAT QUERY TO NwE  PARTICULAR REQUEST.SO IT WORKED.
    NOW AGAIN WHEN CREATING NEW QUERY IT DID NOT ASK FOR ANY NEW REQUEST ,SO I STARTED DESIGNING THE QUERY ,NOW WHEN I RUN THE QUERY DESIGNER WORKBOOK IS OPENING ASUSAL AnD I SEE THE REPORT ,Its  FINE. AGAIN  I WANT TO add ONE VARAIBLE SO I CLICKED CHANGE GLOBAL DEFINITION AN ADDED ONE VARIABLE ,NOW THE WORKBOOK IS NOT OPENING AND ITS JUST IN PROCESS WITHOUT ANY RESULT ,WHY IT HAPPENING ,ONE TIME WORKBOOK I SOPENING AT A GLANCE ANS OTHER TIME WORKBOOK IS TAKING TIME AND ALSO NOT RESPONDING IS THE MESSAGE SHOWN.
    SO WHAT EXACTLY US WORKBOOK 2,3,4 ,5 ETC-----
    HOW TEHSE WORKBOOK NO COME AND WERE OUR REPORT STORES IN WHCH WORkbook
    bye
    satya

    Hi Satya,
    It happens. The window with an input screen for a variable value or for a transport request might be hidden beneath another windows. You need just to switch into the proper window.
    As usual, I click on an icon 'Show desktop' to hide all windows. Then press CTRLALTDEL to invoke Windows input screen, click an a 'Task Manager', then 'Switch to' BEx. After that I can see BEx and its additional windows.
    Best regards,
    Eugene

  • Sql query/function problem??

    Hi ,
    I have problems writing a difficult sql query, please help me
    I have a table t in which there are 50000 records
    the table has columns like
    create table t
    (MATCH_ID     NUMBER(4) NOT NULL,
    TEAM_ID NUMBER(4),
    PLAYER_ID     NUMBER(4),
    RUNS     NUMBER(3))
    here match_id, player_id and team_id are jointly primary key
    SQL> SELECT * FORM T WHERE MATCH_ID < 10
    MATCH_ID    TEAM_ID      PL_ID RUNS
            1          2       1228 8
            1          2       1203 82
            1          2       1316 24
            1          1       1150 27
            1          1       1278 13
            1          1       1243 60
            2          1       1278 37
            2          1       1291 0
            2          1       1243 53
            2          2       1228 25
            2          2       1285 103
            2          2       1316 60
            3          2       1228 8
            3          2       1285 25
            3          2        858 43
            3          1       1278 52
            3          1       1394 6
            3          1       1243 31
            4          1       1278 61
            4          1       1394 6
            4          1       1243 3
            4          2       1228 41
            4          2       1285 40
            4          2        858 5
            6          2       1228 20
            6          2       1285 100
            6          2       1408 0
            7          2       1228 15
            7          2       1285 34
            7          2       1408 44
            8          2       1228 0
            8          2       1420 31
            8          2       1340 66
            9          2       1420 19
            9          2       1385 28
            9          2       1340 0
    .....so on upto 50000 records..
    the problem is that I want to extract how many times each player_id in each
    match exists in the table, prior to that match_id (or current_match_id)
    along with that in another column, I also want the sum of 'RUNS' for each
    player_id  prior to that match_id (or current_match_id)
    my disired output is:
    MATCH_ID    TEAM_ID   player_ID RUNS   NO_OF_OCCURENCES    SUM(RUNS)
                                           BEFORE_THIS_MATCH   BEFORE_THIS_MATCH
                                           FOR_THIS_PLAYER_ID  FOR_THIS_PLAYER_ID
            1          2       1228 8      0                   0
            1          2       1203 82     0                   0
            1          2       1316 24     0                   0
            1          1       1150 27     0                   0
            1          1       1278 13     0                   0
            1          1       1243 60     0                   0
            2          1       1278 37     1                   13
            2          1       1291 0      0                   0
            2          1       1243 53     1                   60
            2          2       1228 25     1                   8
            2          2       1285 103    0                   0
            2          2       1316 60     1                   24
            3          2       1228 8      2                   33
            3          2       1285 25     1                   103
            3          2        858 43     0                   0
            3          1       1278 52     2                   50
            3          1       1394 6      0                   0
            3          1       1243 31     2                   113
            4          1       1278 61     3                   102
            4          1       1394 6      1                   6
            4          1       1243 3      3                   144
            4          2       1228 41     3                   41
            4          2       1285 40     2                   128
            4          2        858 5      1                   43
            6          2       1228 20     4                   82
            6          2       1285 100    3                   168
            6          2       1408 0      0                   0
            7          2       1228 15     5                   102
            7          2       1285 34     4                   268
            7          2       1408 44     1                   0
            8          2       1228 0      6                   117
            8          2       1420 31     0                   0
            8          2       1340 66     0                   0
            9          2       1420 19     1                   31
            9          2       1385 28     0                   0
            9          2       1340 0      1                   66
    as you can see from the above data (5TH COLUMN), i have mentioned the
    existance of each player_id in each match prior to the current_match_id
    since match_id = 1 is the 1st match in the table so no player_id comes in the
    table before match number 1.   
    In match number 2 , player_id = 1278 was also present in match_id = 1 so
    thats why Number_OF_OCCURENCES = 1 for  player_id = 1278 in match_id = 2
    and so on..
    same is the case with 'RUNS' column but here RUNS are the SUM of each
    player_id's 'RUNS' before the current match
    Note: if some player_id does not exist in the table before the current
    match_ID then the query should return zero for that player_id ( as in 4th and
    5th columns of no_of_occurances and sum(runs) respectively)
    for example: in above data
    MATCH_ID    TEAM_ID  PLayer_ID RUNS   NO_OF_OCCURENCES    SUM(RUNS)
                                          BEFORE_THIS_MATCH   BEFORE_THIS_MATCH
                                          FOR_THIS_PLAYER_ID  FOR_THIS_PLAYER_ID
           9          2       1385 28     0                   0
    I hope this will clear my problem
    i would be extremely grateful if someone helps me out??
    here is sample ddl of the above data
    create table t
    (MATCH_ID     NUMBER(4) NOT NULL,
    TEAM_ID         NUMBER(4),
    PLAYER_ID     NUMBER(4),
    RUNS     NUMBER(3))
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1228, 8);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1203, 82);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1316, 24);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1150, 27);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1278, 13);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1243, 60);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1278, 37);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1291, 0);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1243, 53);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1228, 25);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1285, 103);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1316, 60);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 1228, 8);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 1285, 25);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 858, 43);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1278, 52);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1394, 6);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1243, 31);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1278, 61);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1394, 6);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1243, 3);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 1228, 41);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 1285, 40);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 858, 5);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1228, 20);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1285, 100);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1408, 0);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1228, 15);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1285, 34);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1408, 44);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1228, 0);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1420, 31);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1340, 66);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (9, 2, 1420, 19);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values  (9, 2, 1385, 28);
    insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (9, 2, 1340, 0);regards
    ramis.

    Ramis,
    SQL> select * from tt;
      MATCH_ID    TEAM_ID  PLAYER_ID       RUNS
             1          2       1228          8
             1          2       1203         82
             1          2       1316         24
             1          1       1150         27
             1          1       1278         13
             1          1       1243         60
             2          1       1278         37
             2          1       1291          0
             2          1       1243         53
             2          2       1228         25
             2          2       1285        103
             2          2       1316         60
             3          2       1228          8
             3          2       1285         25
             3          2        858         43
             3          1       1278         52
             3          1       1394          6
             3          1       1243         31
             4          1       1278         61
             4          1       1394          6
             4          1       1243          3
             4          2       1228         41
             4          2       1285         40
             4          2        858          5
             6          2       1228         20
             6          2       1285        100
             6          2       1408          0
             7          2       1228         15
             7          2       1285         34
             7          2       1408         44
             8          2       1228          0
             8          2       1420         31
             8          2       1340         66
             9          2       1420         19
             9          2       1385         28
             9          2       1340          0
    36 rows selected.
    SQL> select tt.match_id,
           tt.team_id,
           tt.player_id,
           tt.runs,
           nvl(a.sum_player,0) OCC,
           nvl(b.sum_runs,0) SUM_RUNS
    from
    tt,
    (select a.match_id,a.team_id,a.player_id,a.runs,count(*) sum_player
    from tt a,
          (select match_id,player_id
           from   tt
           group by match_id,player_id) b
    where a.match_id>b.match_id
    and   a.player_id=b.player_id
    group by a.match_id,a.team_id,a.player_id,a.runs
    ) a,
    (select a.match_id,a.team_id,a.player_id,a.runs,sum(b.runs) sum_runs
    from tt a,
          (select match_id,player_id,runs
           from   tt) b
    where a.match_id>b.match_id
    and   a.player_id=b.player_id
    group by a.match_id,a.team_id,a.player_id,a.runs
    ) b
    where tt.match_id=a.match_id(+)
    and tt.team_id=a.team_id(+)
    and tt.player_id=a.player_id(+)
    and tt.match_id=b.match_id(+)
    and tt.team_id=b.team_id(+)
    and tt.player_id=b.player_id(+)
      MATCH_ID    TEAM_ID  PLAYER_ID       RUNS        OCC   SUM_RUNS
             1          1       1150         27          0          0
             1          1       1243         60          0          0
             1          1       1278         13          0          0
             1          2       1203         82          0          0
             1          2       1228          8          0          0
             1          2       1316         24          0          0
             2          1       1243         53          1         60
             2          1       1278         37          1         13
             2          1       1291          0          0          0
             2          2       1228         25          1          8
             2          2       1285        103          0          0
             2          2       1316         60          1         24
             3          1       1243         31          2        113
             3          1       1278         52          2         50
             3          1       1394          6          0          0
             3          2        858         43          0          0
             3          2       1228          8          2         33
             3          2       1285         25          1        103
             4          1       1243          3          3        144
             4          1       1278         61          3        102
             4          1       1394          6          1          6
             4          2        858          5          1         43
             4          2       1228         41          3         41
             4          2       1285         40          2        128
             6          2       1228         20          4         82
             6          2       1285        100          3        168
             6          2       1408          0          0          0
             7          2       1228         15          5        102
             7          2       1285         34          4        268
             7          2       1408         44          1          0
             8          2       1228          0          6        117
             8          2       1340         66          0          0
             8          2       1420         31          0          0
             9          2       1340          0          1         66
             9          2       1385         28          0          0
             9          2       1420         19          1         31
    36 rows selected.
    SQL> Is this do you want ?
    Nicolas.

Maybe you are looking for

  • Lyrics copied from the internet can't be pasted into the song in iTunes

    A few days ago I installed the latest software update, which included a newer version of iTunes, and ever since I installed it I'm experiencing big trouble with adding lyrics to songs in my iTunes. See, if I type in the field of 'Lyrics' there's no p

  • MRP information

    Hi, I am working on ECC 5.0 and got stuck with one of the client requirement. My client want to extract the information about the PO that are created because of some demand.MRP(dependent or independent requirement). Business process is that MRP run->

  • Requirement in Sales

    Hi!! I Just had a requirement in Sales Process. Clients Sales Employee is Based at Customers Place from where he creates Sales Orders. During the process, Customer makes a bargain on Price of a product. Now Sales Employee cannot create Sales order on

  • [svn] 3932: Integrate revision 3913 and 3922 from 3.0.x (aka Blaze 3.2):

    Revision: 3932 Author: [email protected] Date: 2008-10-28 12:33:43 -0700 (Tue, 28 Oct 2008) Log Message: Integrate revision 3913 and 3922 from 3.0.x (aka Blaze 3.2): BLZ-272 Two long polling endpoints not working in same app. The long polling waitMon

  • How can I uninstall imovie '09 and then reinstall it?

    My imovie is not working as it should, and the only thing I can think of to do is to uninstall it and hope that it will then be working properly again when I reinstall. Can anyone help please?