Query - Counting customers based on Top 80% condition

Hi all,
We have a query, which counts the number of customers that makes up 80% of the sales. We have used a condition to do this.
This works out quite well when we only have the customer in the drill down. However if we also include f.x. Division in the drill down the system count the values incorrectly.
We have previously solved a similar situation with exception aggregation. However it seems like the system ignores the condition when using exception aggregation.
Does anyone know how this can be solved ?
KR Mikkel

I got the answer on my own :)
SELECT CASE WHEN count(RW."CountofBATCH") > 1 then 'Mixing'
WHEN count(RW."CountofMAT") = 0 then 'None'
ELSE 'Other'
END
FROM TABLENAME TT, XMLTable('/Rowsets/Rowset/Row' PASSING TT.XMLCOL
COLUMNS
"CountofBATCH" PATH '/Row[CLABS > 0]/BATCH',
"CountofMAT" PATH '/Row[MAT = "[Parameter Value]"]/MAT'
) AS RW
where
some condition

Similar Messages

  • BDC select query with addition based on all If conditions

    Hi can any one send me the select query with conditions like
    If Itab is not initial.
    Endif. and if possible with valiadations messages also.
    IF CHECK_NUMBER of CHECK_ADVICE of the flat file = PAYR-CHECT. Then update SAP field BSEG-XREF2 .
    9.     When Flat file check Number = PAYR-CHECT then Insert or Update Flat file RECEIPT_DATE into SAP field BSEG-XREF1.
    Please send me immediately.

    >     SELECT rsnum
    >            rspos
    >            matnr
    >            werks
    >         lgort
    >            shkzg
    >            aufnr
    >            bdmng
    >            enmng                      
    >            FROM  resb INTO  TABLE it_rsnum FOR ALL ENTRIES IN it_aufnr
    >            WHERE rsnum EQ it_aufnr-rsnum
    >            AND   xloek NE 'X'
    >            AND   postp NE 'X'
    >            AND   resbbdmng GE resbenmng.
    >   ENDIF.
    >
    > Database Table RESB: 40,000,000 Records (40 Million)
    > Internal Table   it_aufnr:  20,000 Entries
    > Entries selected from RESB: 150,000.
    >
    Hi,
    the problem is the big for all entries table.
    Your 20.000 records FAE will be split into SEVERAL sql statements depending on the size of the table.
    Where do you get the it_auftrn from?
    If it's another transparent table try to JOIN this table to your big table.
    SELECT rsnum
                rspos
                matnr
                werks
            lgort
                shkzg
                aufnr
                bdmng
                enmng                      
                FROM  resb JOIN tab_auftrn  on  resbrsnum = tab_auftrnauftrn
                AND   xloek NE 'X'
                AND   postp NE 'X'
                AND   resbbdmng GE resbenmng.
    Make sure that your WHERE filter and the JOIN keys on both tables are supported by indexes.
    150.000 records about of 40 Mio. can definitly be serviced by an appropriate index:
    i.e. Index fields (check your PK or secondary indexes):
    rsnum
    enmng                      
    aufnr
    bye
    yk

  • Query with Top N Condition (Result Row)

    Hi,
    I made a query with an active top n condition. The query has 2 Keyfigures and 1 formula
    Gross-sales acutal | Gross-sales previous year | Previous Year %
    So that to result line is correct, I had to say "Calculate result as summation" for the keyfigures
    gross sales actual and gross sales previous year. That works.
    I have the problem with my formula. the formular for previous year % is defined as follows:
    gross sales actual %A gross sales previous year
    Example Top 3 Customer
                        gross sales actual          gross sales prev. year         prev. year %
    Cust 1          100                                   80                                       125 %
    Cust 2          90                                     45                                        200 %
    Cust 3           80                                    60                                        133 %
    Result          270                                   185                                       142.8 % ( 350 * 100 / 245 )
    The result of 142 % is the correct result without the condition top 3. with the top 3 condition
    the result should be 270 * 100 / 185 = 145.9 %
    Additional customer without top 3 condition
    Cust 4          50                                       40                                        125 %
    Cust 5          30                                        20                                        150 %
    It shows the correct result for each single line. The result in the result row is wrong. it is calculated
    without taking the active condition. the formular calculates
    with the total gross sales actual and the total of gross sales prev. year.
    is there any solution the achieve the correct % in the result row?
    thanks for your help.
    Pascal

    Pascal,this is a known behavior with conditions.When you apply condition it just hide the extra rows and it does not impact the result row.So your result row actually shows the value irrespective of the condition you apply.
    Now with the help of local functions like calculate result as summation you can show the correct sum after applying the condition but when you try to use that result in some calculation then it takes the original value thereby discarding the calculated value.
    Same is happening in your case as well.Its taking the original value i.e 350 and not the calculated sum after condition i.e 270.
    Hope this helps.
    Regards,
    AL

  • Query based Infoset doesnt accept condition...

    Hi
    In BI, My Bex designer query is based of an infoset. This query works fine without condition, but if i give condition in the query, it doesn't work & give message:
    "Could not find any data to display. This might be due to the current selection of variable or filter values"
    Even as per query condition, i have data in infoset. Could u pls. let me know wht should i do?
    Thanks...

    Any Suggestion would be appreciated.
    Actually query on inofset working fine but once i put condition of PO delivered Qty = 0, it doesn't give any query output whereas data exists for this condition in infoset

  • About the top N condition in WAD web template

    Hi all experts,
    I'm facing a problem in my WAD web template. Hope you guys can give me a hand.
    In my web template, there is analysis item A and B.
    Table A are used to display top 3 customers(char) with highest purchase rate % (KF), I'm using top N condition to select top 3 customers.
    And table B is to show all customers with purchase rate, sorted from highest purchase rate to lowest (logic:- sort the KF(purchase rate) in descending order)
    The problem is when there is many customers with purchase rate = 100%(more than 20 customers), then for the 1st-3rd customers of table A and B, the selected and sorted customers results are not the same, shouldn't that they should be identical for the 1st three rows as they are trying to show customers with highest purchase rate? even though table A is using top 3 condition and table B is using descending sorting for purchase rate.
    For example:- Top 3 customers in table A and all customers in table B
    Table A                                            
    Customer       Purchase rate             
    c3                  100%                             
    c1                  100%                            
    c5                  100%                                                                               
    Table B
    Customer    Purchase rate
    c2              100%
    c3              100%
    c4              100%  
    c1              100%
    c5              100%
    c6              81%
    c7              58%
    In this example, table a and b have selected different customers for 1st to 3rd position, i'm trying to make them showing identically. Any suggestion?
    Perhaps you guys can give me some idea on how does the top N condition determine the TOP 3 customers if there is many customers with 100% purchase rate as in this case.
    Thanks a lot,
    Eric
    Edited by: Eric Tan on Aug 12, 2008 10:49 AM

    When u create conditions, you have tab called CHARACTERISTIC ASSIGNEMENT.& other is GENERAL..which is like in what way you want to create conditions i.e based on which characteristic or whole characteristic in rows etc...you try choosing those option in that tab, so that you can find some ideas..

  • Top 10 Condition and Zero Suppression

    I have a query that has a zero suppression turned on, so that rows/columns that have no values are suppressed.
    I have added a condition to the query such that only the top 10 are displayed.
    The problem is that the condition appears to be applied after the zero suppression. The result is that when the top 10 are displayed, it is displaying blank columns, as there may be values in a column, but none of them fit into the top 10 criteria.
    Does anyone know how I can suppress the zero columns/rows when the top 10 condition is active as well.
    Thanks in advance for any assistance.
    Regards
    Richard

    Hi Anil,
    Thanks for the response.
    Unfortunately the column(s) that are to be hidden will change depending on the data, so this will not work.
    ie. if you consider a query that has products on the rows, customer across the top, and there is a top 10 condition on the net sales of the product, so I will always have 10 rows of products, but the number of columns will vary, depending on how many customers have bought that product.
    Thanks again for your suggestion.
    Regards
    Rich

  • Availability of material based on the shipping conditions

    Dear Friends,
    Please mail to me how to configure the availability of material based on the shipping conditions?
    That is when we give the shipping condition in the sales order (va01) for example by air 1 day, by road 5 days and by water 6 days. The system should automatically give the availability of the material based on the shipping conditions we give in the sales order (va01).
    With regards

    vamsi krishna wrote:>
    > Dear Friends,
    > Please mail to me how to configure the availability of material based on the shipping conditions?
    > That is when we give the shipping condition in the sales order (va01) for example by air 1 day, by road 5 days and by water 6 days. The system should automatically give the availability of the material based on the shipping conditions we give in the sales order (va01).
    > With regards
    Hi Vamsi,
    Could not understand your query fully.
    See material availability check is carried out for the requested delivery date or else the system proposes one.
    The time you are talking about By Air 1 day and so on is not taken into consideration while carrying out material check for that is transportation time after goods are released from the Plant.
    owever if you need to configure the transportation time you need to go to
    Logistics Execution->Transportation->Basic Transportation Function->Routes->Define Routes-> Define shipping types
    Here you can define shipping types what you said by AIR by Truck or whatever you need.
    To specify the time you need to go to SPRO
    Logistics Execution->Transportation->Basic Transportation Function->Routes->Define Routes-> Define Routes and Stages
    Here you specify the Transit Duration Transit Lead time and so on which will be taken as a input for determining material lead time by that shipping type.
    Hope it helps.
    Post if u need furthur clarifications.
    Request you to reward points if helpful.
    Thanks & regards
    Abhishek Swarup

  • Getting SQL*Net more data from client waits when running a query through web based interface

    Hi, you all,
    We are having this weird behavior when running query through web based interface, we get a lot of "SQL*Net more data from client" waits, the OEM indicates that the current wait event is SQL*Net more data from client
    It's just a very simple query wich invokes a db link.
    When I execute the same query on any PL/SQL tool like toad or sql developer it works fine, but that query inside an application executed through a web based interface, it hangs for ever.
    Where can I start looking for the problem.
    We are working on a 3 Node RAC 11gr2, both databases are on the same RAC.
    Thanks.

    Hi ,
    we managed to reproduce the case in test environment, below are the steps:
    1)have 2 databases on different machines, will call the first one local, the other one remote.
    2)in the local database create:
    a - DBLink to remote database.
    b - read data from remote database(we simply used select count(*) from dummy_table )
    c - insert data into a table on the local database
    d - terminate the connection between the 2 databases (disconnect either machine from the network)
    e - commit on local database.
    what we noticed was the following:
    1)when the local database is disconnected from the network(the machine is not connected to any network at the moment): almost immediately throws an error, and issuing the following:
    select * from dba_2pc_pending;we found some data .
    2) when the remote database was disconnected(the local database is still connected to the network):
    after 7-8 seconds an error is thrown, and issuing the following:
    select * from dba_2pc_pending;did not return any data.
    since this is pretty similar to our case ,we concluded that it's a network issue.
    is this the correct behavior ?
    as a temporary solution till the network issue is fixed ,we did the following:
    1) changed the call of the remote procedure to calling a local procedure that calls the remote procedure.
    2) added pragma autonomous_transaction to the local procedure.
    3) at the end of the local procedure rollback the autonomous transaction.
    it seems that since the global transaction does not use the DBLink database does not issue a 2PC commit.
    this works in my cases since the DBLink is only issed to read data.

  • I want to retrieve data from p0001-PLANS based on the below condition,

    Hi,
    I want to retrieve data from p0001-PLANS
    based on the below condition
    select stext from hrp1000 where plvar = '01' and otype = 'S' and objid = p0001-plans and begda GE pn-begda and endda LE pn-endda.
    Thanks,
    Rama.

    Hi
    Based on the Query you have specified thoise are stoerdin an Internal table- then
    select stext from hrp1000 into table t_hrp where plvar = '01' and otype = 'S' and objid = p0001-plans and begda GE pn-begda and endda LE pn-endda.
    The check table for this PLANS is T528B .
    if t_hrp[] is not intitial.
    select * from t528B intot table t_528 where plans eq t_hrp-plans.
    endif.
    Now you can get the PLANS data.
    Refer to the Text tbale for PLANS -  T528T
    To get the TEXTS -
    if t_hrp[] is not initial.
    select * from T528T into table t_528T where plans eq t_hrp-plans.
    endif.
    Regards
    Lekha

  • How to cummulate the quantity based on the date condition?

    hi,
         In my query,i need to cummulate the open quantity based on the two date condition.
    If my Schedule line date > system date, i need to cummulate the open quantity.
          But in my query level i am getting 0 or 1 based on the above condition.
          i am struggling to cummulate the open qty based on the above condition.
        can any body throws an idea to resolve my issue.
    Regards,
    ravi.

    Thanks for suggestion,Almost i narrow down my issue to get the proper result.
    But  i have one doubt.
    Is it possible to user Formula variable  (Processing by replacement path-Reference char as Scheduline date) in my  Calculated Key Fig calculation.?? But here i am created  Scheduline date as Characher infoobject.
    Actually i am created Scheduline date as Character InfoObject,If i am using the following condition like
    (Schedule line date > system date) its throwing "X" value.
    For the above issue,if i am changing the Scheduline date as Key figure InfoObject means i will get the proper output for the condition(Schedule line date > system date) either 0 or 1.
    Is it correct????
    Regards,
    Ravi.

  • Report for Pending 103 for 105 (If GR based IV is untick condition)

    Hi,
    I required logic for mapping the report in Pending 103 for 105, If GR based IV is untick condition in PO.
    Our business accept the material with movement type 103. After various tests (outside SAP), we post this document with movement type 105.
    Normally each MIGO document has a reference document no . In case of 103 document, the reference docu no is the same no. In case of 105 document, the reference docu no is the docu no of 103.
    It is noticed that for some 103 and 105 documents, the reference docu no is blank when GR based IV is not ticked in the Purchase order.
    We need some logic to find the ref of 103 doc in 105 doc.
    Regards,
    Maddali

    Thanks for your promt reply.
    I have seen ME2M/ ME2L with selection parameter we104 or we105. However our client required specific report format for controlling this issue.
    So I am trying for logic in this particular senarieo.
    Regards,
    Suresh

  • QUERY FOR CUSTOMERS FULL DEBIT AND CREDIT WITH CLOSING BALANCE

    Hi Friends,
       I need query for CUSTOMERS FULL DEBIT AND CREDIT WITH CLOSING BALANCE for selection criteria from date and to date.
       I know the Trial Balance Report will sort out this issue... but i need routeday wise report
    1. Business Partner Master Data - i created one UDF field called U_Routeday (MONDAY, TUESDAY, WEDNESDAY,THURSDAY,FRIDAY)
    2. The query should be like selection criteria 
                                  - Routeday [%0]
                                  - Posting Date [%1]                           
                                  - Posting Date [%2]
    CardCode
    Debit
    Credit
    Balance
    D10503
    25031.50
    24711.50
    2962.00
    D10641
    5466.00
    7460.00
    285.00
    D10642
    2866.00
    142.00
    give any helpful query ASAP... Thanks in advance

    Hi,
    Try this query:
    Declare
    @fromdate as datetime
    Declare
    @Todate as datetime
    Declare
    @Code as nvarchar(25)
    set
    @fromdate = ( select min(Ta.[RefDate]) from OJDT ta where
    Ta.[RefDate] >= [%0])
    set
    @Todate = ( select max(Tb.[RefDate]) from OJDT tb where Tb.[RefDate]
    <= [%1])
    set
    @code = (select max(Tc.[ShortName]) from JDT1 tC where Tc.[ShortName]
    = [%2])
    SELECT
    [Name] as AcctName, [Jan]= sum([1]), [Feb]= sum([2]), [Mar]=
    sum([3]), [Apr]= sum([4]),  [May]= sum([5]), [June]= sum([6]),
    [July]= sum([7]), [Aug]= sum([8]), [Sept]= sum([9]), [Oct]=
    sum([10]), [Nov]= sum([11]), [Dec]= sum([12]), total = sum
    (isnull([1],0)+ isnull([2],0) + isnull([3],0) + isnull([4],0) +
    isnull([5],0) + isnull([6],0) + isnull([7],0) + isnull([8],0) +
    isnull([9],0)+ isnull([10],0) + isnull([11],0) + isnull([12],0))
    from
    (SELECT
    T0.[ShortName] as Name, sum(T0.[Debit]-T0.[Credit]) as T,
    month(T2.[RefDate]) as month FROM JDT1 T0  INNER JOIN OACT T1 ON
    T0.Account = T1.AcctCode INNER JOIN OJDT T2 ON T0.TransId =
    T2.TransId WHERE T2.[RefDate] between @fromdate and @todate and
    T0.[ShortName]  = @code  GROUP BY T0.[ShortName],T2.[RefDate] ) S
    Pivot
    (sum(T)
    For  Month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
    group
    by [Name],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]
    Let me know your result.
    Thanks & Regards,
    Nagarajan

  • Conditional Display of A region based on a Search condition

    Hello All,
    I would really appreciate any suggestion and pointers on how to achieve the below.
    My requirement is to display a tabulated result based on a search condition.
    I have two regions. One region contains the items to enable a search and the other region will be used to display the search results.
    Region A is an HTML region containing three items
    1.     A text field: to enter the search text
    2.     A list field: to determine the type of entity to search (customer_id, invoice number, Passport No)
    3.     A button: to initiate the search process.
    Region B is a reports region displaying the search results
    My question is:
    1.     Is basing the source of the region as a “PL/SQL function returning a select statement” the ideal choice. I will have variable “WHERE” clauses based on the search criteria entered in region A. However, the columns returned will always be the same
    2.     How do we get the region B to display only when there are results returned from the search results
    3.     How do we base by result set based on a stored procedure in the database. Basically as an API. We pass in the parameters and the API passes the result set back to APEX. This way, I can have all the DML hidden behind the stored procedures
    Looking forward to your comments and suggestions
    Pravind

    Hello,
    See the below link
    Re: item dispaly conditionally
    Regards,
    Shijesh

  • How to query a row based on its rownum

    Dear all,
    what is the easiest way to query a row based on its rownum? Suppose I have the following query:
    select first_name from employees where rownum<5;
    FIRST_NAME
    Ellen
    Sundar
    Mozhe
    DavidSo Ellen has rownum 1, Sundar 2 and so on. How can I do it if I just want to query a row where Mozhe is the first_name, which is rownum 3?
    Best regards,
    Val

    JS1 wrote:
    Valerie Debonair wrote:
    I was thinking how oracle assign a rownum in a table is by how it populates the rows in the table.Hence a statement "based on its availability". Maybe my way of thinking it's not accurate?
    You are correct, your way of thinking is wholly innaccurate. Something that can easily be confirmed simply by reading the documentation:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns009.htm#i1006297
    okie doke... thanks for the correction

  • Classyfying the customers based on their sales

    Hi,
    I have report showing the cutomers and the sales units to them
    for example:
    customer     sales
    A     200
    B     300
    C     50
    D     100
    how can i grade the customers based on their sales, for example
    Grading                customer     sales
    Gold >=300            B              300
    Sub total                   300
    silver >100 & <300    A              200
    sub total                   200
    Bronze <=100          C               50
                       D              100
    sub total                   150
    Could anyone please help me
    Message was edited by:
            rapo
    Message was edited by:
            rapo

    Thanks ganesh and ramesh,
    Thanks for your inputs.
    By exceptions, i can get classigy them and even color them and sort them but i cannot get the sub totals for each classification.
    Ramesh, can you please clarify in detail how this can be done by using the formula.
    thanks and regards

Maybe you are looking for

  • Windows 8.1 on Macbook White Mid 2010!

    Hey! I installed Windows 7 on my Macbook White unibody mid 2010 model. When I got it I noticed that I needed Windows 8 an application I'm using alot so I installed it. When I installed it I had to install boot camp to get my sound to work and the spe

  • Connecting 8800 to a Noki car Kit

    Does anybody know how to connect up to a Nokia car Kit. When I try and pair via bluetooth to the device it recognises the car kit but says that it cannot connect. Is there a compatability problem? Thanks Conker

  • HT201210 cannot restore ipod due to passode and new laptop

    Hi, this is a tough one! Daughter disabled ipod touch with wrong passcodes. I have since got a new laptop which this ipod was not synct to. Therefore itunes does not recognise it and will not restore, even in recovery mode. HELP! lol

  • 2004 G5 iMAC ad compatible scanners

    I'm just about to purchase a flat scanner to go with my G5, which now has 10.5.8 OSX Leopard softwear. I'm not sure whether this G5 has a USB 1.1 or USB 2.0 port. Questions: 1. Does anyone know how to find out? 2. If it's only USB 1.1 - what do I do

  • Puting pictures of Documents in a pod cast

    I want to create a pod cast with pictures of documents, when I put them into garage band they look very good, when I make a pod cast they become fuzzy. Any ideas on how to clear up the picture?