Conditions in Query

Hi all,
For the top 1 to 10 customers  i created a condition of Sales TopN and 10. I now need to display the top 10 to 20 customers in another query. How can I do this?
Cheers~

Hi,
Two conditions in the same query have the logic AND, so you could try the logic:
Condition1 Top 20       +    Condition2 Bottom 10
But I'm afraid the precondition is that you have to add a filter to the query to make sure that only 20 customers will appear in the result set (actually, then Bottom 10 itself will work). Any way, just have a trial. And also refer to:
http://help.sap.com/saphelp_tm60/helpdata/en/43/2695d2fd2f0d23e10000000a1553f7/frameset.htm
Hope it can give some help.
Regards,
Qing

Similar Messages

  • How to Use MAX condition using Query Report

    Hi SAP Abap Expert,
    Can we use the MAX condition in Query Report (SQ01/SQ02) ?
    I have created one sample query using table VBRP and VBRK then i need to use max condition to get the MAX record in VBELN.
    Please Help ???

    Hi Ashishsingh,
    According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
    http://technet.microsoft.com/en-us/library/ms145601.aspx
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • What is the use of Condition is Query Designer  ??

    What is the use of Condition in Query Designer  ??
    How to use condition in   Query Designer  ??

    Hi,
    Conditions in a query can be defined for both characteristic combinations and key figures.
    Characteristic combinations can be used using the ranking list functionality (e.g Top N or Last N customers with highest sales).
    Key figures can be assigned the value limit conditions ( for e.g. display only rows in the query for which the key figure > 10 ).
    For your specific requirements in which you need to display only a limited set based on the key figures, then you can go for conditions.
    The conditions can be allowed to work on all the drill down characteristics independently, single characteristics or combination as well based on your requirement.
    While execution the report, you can activate or deactivate the condition anytime by right clicking on the data cells.
    Regards,
    VA

  • CAN WE HAVE IF CONDITION IN QUERY GENERATOR

    Hi friends,
    am, trying to make use of if condition to obtain a set of values in query generator.  Its possible to retrieve the required result set using query analyser but not in query generator.  am trying to execute the following query
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 1 and owor.itemcode = '100-100')
    begin
                    select itt1.u_reactor1 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    else
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 2 and owor.itemcode = '100-100')
    begin
         select itt1.u_reac_23 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    else
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 3 and owor.itemcode = '100-100')
    begin
         select itt1.u_reactor4 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    if it is not possible to write such query in query generator  can someone help me with a workaround solution.
    Thank u
    Vaitheeswaran

    Hi,
    I dont think Nested IF Statements are allowed in PLD. The reason that u get the result in Query analyser and not in Query Generator is that SAP supports Transact SQL and many SQL Server 2000 functions are not supported.
    However there is a work around in Print Layout Designer for using IF condition by having Linked Objects. Kindly see some tutorials regarding Linked fields available on SDN site and think of some other way of implementing this nested IF query.
    Regards
    Rizwan Hafeez
    Team Lead
    SAP Addon Development Section
    Abacus Consulting - Pakistan

  • How to use many conditions in query

    Hi all,
    i have a situation,must prepare a report to find availability of it devices.they are given the specific ip of devices.
    my query
    SELECT 
     Resultdate, [SERVICE]  ,[SERVICE TYPE] ,[IP]
    , DailyAvailability
      FROM [Orion].[dbo].[DepartmentNodesNew] t1
    left join (   select round(1-(sum([DownTimeMin])/(1440*count(*))),4)*100  as DailyAvailability,
      count(*) as Node,   c2.ResultDate  ,[Departament]  ,[IPAdress]
       from  [Orion].[dbo].[OrionEventsNodeDownTime] as c2 group by  [Departament] ,[IPAdress] , c2.ResultDate) t2
       on t1.IP=t2.IPAdress 
       where t2.DailyAvailability is not null and t1.SERVICE='SAP CRM' and t2.ResultDate='2014-12-10'
        order by ResultDate
    now how can i calculate the daily availability of sap crm which have 2 servers and they are in cluster,when one is down service is ok.when both of them are down service is off. how can i calculate by writing conditions.
     case when  ([SERVICE]='SAP CRM' AND [SERVICE TYPE]= 'DB Server' and [DownTimeMin] =0) then DBAvailability 100
      else  then DBAvailability select round(1-(sum([DownTimeMin])/(1440*count(*))),4)*100 ???

    SELECT Resultdate
    ,[SERVICE]
    ,[SERVICE TYPE]
    ,[IP]
    ,DailyAvailability
    INTO #TempTable
    FROM [Orion].[dbo].[DepartmentNodesNew] t1
    LEFT JOIN (
    SELECT round(1 - (sum([DownTimeMin]) / (1440 * count(*))), 4) * 100 AS DailyAvailability
    ,count(*) AS Node
    ,c2.ResultDate
    ,[Departament]
    ,[IPAdress]
    FROM [Orion].[dbo].[OrionEventsNodeDownTime] AS c2
    GROUP BY [Departament]
    ,[IPAdress]
    ,c2.ResultDate
    ) t2 ON t1.IP = t2.IPAdress
    WHERE t2.DailyAvailability IS NOT NULL
    AND t1.SERVICE = 'SAP CRM'
    AND t2.ResultDate = '2014-12-10'
    ORDER BY ResultDate
    SELECT Resultdate
    ,[SERVICE]
    ,[SERVICE TYPE]
    ,[IP]
    ,DailyAvailability
    ,CASE
    WHEN (
    [SERVICE] = 'SAP CRM'
    AND [SERVICE TYPE] = 'DB Server'
    AND [DownTimeMin] = 0
    THEN 100
    ELSE round(1 - (sum([DownTimeMin]) / (1440 * count(*))), 4) * 100
    END AS 'DBAvailability'
    FROM #TempTable
    -Vaibhav Chaudhari

  • Use of Conditions in query

    Hi,
         While using conditions, there are 2 options mentioned
    1.all the characteristics in the drill down independently
    2.Single characteristics or combination of characteristics
    Can someone explain me the above two with examples?

    Hi,
    This property would allow to choose if we would like to apply the conditions to all the characteristics or particular characteristic.
    Typically we select - All Characteristics in the Drilldown Independently
    This setting allows you to apply a condition in a general way. Depending on which characteristics you use in the drilldown, you obtain different results.
    Single Characteristics and Characteristic Combinations
    This setting allows you to evaluate the condition for characteristics or characteristic combinations defined for specific drilldowns only. You can select any characteristic (of the characteristics used in the query in rows, columns, or in the free characteristics) or a characteristic combination.
    Thanks.

  • How to put this condition in Query

    Dear experts,
    I have a scenario where in the calculation should be dynamic between key figures in query
    For example i have a
    Target Cost and Actualcost1, Actualcost2, Actualcost3
    i need to findout the variance between the Target and Actual
    but the catch is that i need to findout the variance with the latest actual cost
    1. )  Target cost = 100
    Actual cost1=10, Acutal cost2=0, actual cost3=0
    then the formula should be Actual cost1-target cost
    2. )But if
    Target cost  =100
    Actual cost1=10, Actual cost2=5, Actual cost3=0
    then the formula should be Actual cost2- Target cost
    3. Target cost =100
    Actual cost1=10, Actual cost2 = 5, Actual cost3= 15
    then the formula should be Actual Cost3-Target cost
    How to achieve this
    Thanks and regards
    Neel

    Hi Neel,
    Do you have indicator saying that a particular actual cost is the latest? If you have any indicator thsi would make the job easy. Else you need to create new formulas to derive the logic.
    Else you can proceed with the belwo logic.
    1.target cost
    2. Actual Costs 1 - Hide
    3. Actual Costs 2 - Hide
    4. Actual Costs 3 - Hide
    5. New formula whcih evaluates the latest.
    Write the condition
    If Actual costs3 = 0 and actual cost2 = 0 then actual cost1.
    else if actual cost2= 0 then actual cost1
    else if actual cost1 NE 0 and actual cost2 NE 0 then Actual cost3.
    Then hide the above new formula.
    And in a new formula you can find the diff between the Target cost and the latest cost derived in teh above new formula.
    If the conditions is too big in the above new formula, you can split across two three new formulas and derive the logic.
    Just make some changes to the above logic if it is not 100%.
    I believe this logic will work.

  • Filter condition in query designer

    Hi Friends,
    Can any one please tell me?
    Query is done on Multiprovider (made of Cube 1 to Cube 6 ) and in query designer under filter tab i have seen
    case 1:
    1) Fiscal year variant F4
    2) Cube 1
    Questions:
    1) what is the use of Fiscal year variant F4 in this case?
    2) Field 1 is available in all 6 cubes. In report from which cube the data is retreived for this filed 1?
    Next case 2:
    Under filter condition
    1) Fiscal year variant F4
    2) Cube 1 and cube 2
    Question: Field 1 is available in all six cubes. in report from which cube the data is retrevied for this field 1.
    Thanks
    Tony

    We have a similar situation with three cubes.  However, when we run the query in Q, the filter (restriction) works well and we get the output only from one cube.
    When the query is moved to Production (transport), with same restrictions, the query is not getting restricted for one cube initially, but hitting all three cubes in the multi provider...and hence taking a much longer time to process..
    Any ideas what could be going wrong (the query is on an aggregate level, for IP)

  • Multiple conditions in Query doesn't work

    Hi all,
    I've made a query pointing on a Multiprovider wich 's made of two main dimension ( multiple infoproviders ) :
    contract and pricing and on the other hand  Sales and Revenues.
    In my Query, one condition's concerned by a contract & pricing key figures ( Number of pricing condition > 0 ), and another one is about a Minimum Turnover Sales & Revenues key Figures restriction( by a prompt ).
    This doesn't match, Some rows are missing, and while a condition is active , the other one can't be..
    If any one meet this kind of problem before ?
    Thanks and sorry for my bad english..

    Hi,
    I already try to create another key figure wich made like this :
    Number of condition * Turnover
    and made a condition on this result.
    But the main problem is  if the contract doesn't have Turnover, it will not shown the rows with condition ..( the condition is on the single value 'number of document ) and if I put anotehr condition with number of condition > 0, it still doesn't work..
    thanks for help.

  • Issue with condition in Query

    Hi,
    I have report on a cube which when  execute vit all main characteristics(highest level char[plant] to lowest level[material] chars) like plant, external-material grp, material type, project-plant and material the report vil come vit correct values , wen v remove the lowest level ie., material the overall result is changing.
         There is a condition for Godown Quantity(godown qty notequalto  0)
        Because of the condition on godown qty the overall result is changing.
    like:
    qty 61-120amt 61-120qty >120----amt >120
    10936.06-766957.91-1955762.54--725613332.2(overall-results)
    when we drill down are remove drill down any characteristic then some value(6422) of amt61-120 days  is shifting to amt>120days,this happening  also for qty.
    like:
    10934.66760535.291955763.94---725619755(overall-results)
        so i removed the condition and executed the report, here wat ever char v remove and wat ever char v drill down no effect to over all result means it vil remain unchange.
       But asking for no zero values for Godown quantity.
    Help me in this....
    Thanks in Advance,
    Chaitu.
    Edited by: chaithu218 on Jun 6, 2011 5:09 PM

    Hi,
    user555994 wrote:
    Hello Lee,
    thanks for your reply.
    But what is B?I think Lee meant to name the in-line view "B", like this:
    SELECT b.app_req_id
    FROM  (SELECT   a.app_req_id,
                    COUNT(*) cnt       -- or maybe COUNT (DISTINCT a.class_symbol)
           FROM     app_req a
           WHERE    a.class_symbol IN ('MBA', 'BTECH', 'BBA', 'SENIOR SECONDARY', 'SECONDARY')
           GROUP BY a.app_req_id)  b     -- Alias added here
    WHERE  b.cnt = 5
    ;You don't really need either alias. In fact, you don't need the sub-query: the query below is equivalent to the one above:
    SELECT    app_req_id
    FROM      app_req
    WHERE     class_symbol     IN ('MBA', 'BTECH', 'BBA', 'SENIOR SECONDARY', 'SECONDARY')
    GROUP BY  app_req_id
    HAVING    COUNT (*)           -- or maybe COUNT (DISTINCT class_symbol)
                     = 5
    ;If the combination (app_req_id, class_symbol) is not unique, then use "COUNT (DISTINT class_symbol)" instead of "COUNT (*)".
    There is only 1 table i am reffering to and need to get the ID where values matches in other column. Other column can have the values as that of MBA,BTECH,BBA,SENIOR SECONDARY and SECONDARY.
    I don't want to use query as -
    Select APP_REQ_ID FROM app_req where class_symbol in ('MBA', 'BTECH', 'BBA', 'SENIOR SECONDARY', 'SECONDARY')
    As this will be with either of the match found. I want where all of the match found.That's what the condition "WHERE b.cnt = 5" in the main query is for.
    >
    Kindly help.If the query above is not doing what you want, then post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data. Point out where the query above is getting the wrong results, and explain, with spoecific examples, how to get the right results in those places.

  • How to conditionally write  query ?

    i have one use case -
    on the basis of enter value i need to execute query .
    for example
    select * from employees em where em. empId=? and em.firstname=? and em.jobid=?
    select * from employees em where em. empId=? and em.firstname=?
    i need to the write one query which is internally used this both condition and return the records
    select * from employees em where
    if(em.jobid==null)
    select * from employees em where em. empId=? and em.firstname=?
    else
    select * from employees em where em. empId=? and em.firstname=? and em.jobid=?
    how could i write this problem in sql ?

    Note the name of this forum is "SQL Developer *(Not for general SQL/PLSQL questions)*" - so only for issues with the SQL Developer tool. Please post these questions under the dedicated SQL And PL/SQL forum.
    Regards,
    K.

  • *** How to add dynamic condition to Query ***

    Hi All,
    Could you please help me out logic
    i need only query
    There is tables emp, dept
    SELECT E.ENAME,D.DNAME
    FROM EMP E, DEPT D
    WHERE d.DEPTNO = e.DEPTNO(+)
    AND (DYNAMIC CONDITION)
    DYNAMIC CONDITION LOGIC IS
    IF D.DEPTNO IS THERE IN E.DEPTNO THEN [E.JOB = 'MANAGER'] --- CONDITIION SHOULD ADD IN THE PLACE OF (DYNAMIC CONDITION)
    IF D.DEPTNO IS NOT THERE IN E.DEPTNO THEN [ D.LOC = 'LONDON'] --- CONDITIION SHOULD ADD IN THE PLACE OF (DYNAMIC CONDITION)
    I tried below
    select e.ENAME, e.SAL, d.dname from emp e, dept d
    where CASE WHEN e.deptno = d.deptno then e.job = 'MANAGER'
    else D.loc = 'LONDON'
    END
    But its giving error...
    Please give a solution
    Thanks in Advance
    KC

    SELECT E.ENAME,D.DNAME, d.loc, e.job, e.deptno
    FROM EMP E, DEPT D
    WHERE d.DEPTNO = e.DEPTNO(+)
    and (
           (e.deptno is null and d.loc='LONDON')
             or
           (e.deptno is not null and e.job='MANAGER')
         );  (But thats no dynamic sql!)

  • Regarding Conditions in query

    Hi
    I have created a condition to display Top 10 company codes based on a formula in my development system.Tested it and its fine.Transported it to Quality and it displayed me 10 Company Codes.But in Production ,it displayed me only 6 company codes.The data in Production and Quality are same then why arent they displaying me the top10 company codes.
    Regards
    Bharath

    Bharat,
    Is the data completely loaded in the Cube?
    Try validating the results between Quality & Production using a simple query without conditions.
    See if the query is showing data in production for all company codes if there are no conditions.
    Hope it helps!
    amol

  • Conditional columns  query

    hi
    Iam trying to write a query which is as follows
    select A1,A2,A3,A4,A5,A5,A6,A7 from table.
    such that columns A1,A2,A3 must be displayed only when A1 is not null
    and columns A4,A5,A6 must be displayed only when A4 is not null.
    any help..
    thanks
    Kumar

    Alternatively:
    SELECT NVL2(a1, a1, NULL) a1, NVL2(a1, a2, NULL) a2, NVL2(a1, a3, NULL) a3,
           NVL2(a4, a4, NULL) a4, NVL2(a4, a5, NULL) a5, NVL2(a4, a6, NULL) a6
    FROM <table_name>;NVL2 demos here:
    http://www.morganslibrary.org/reference/misc_func.html#mfn2
    SQL> create table test1 (
      2  a1 number,
      3  a2 number,
      4  a3 number,
      5  a4 number,
      6  a5 number,
      7  a6 number);
    Table created.
    SQL> insert into test1 values (NULL,1,1,1,1,1);
    1 row created.
    SQL> insert into test1 values (1,1,1,NULL,1,1);
    1 row created.
    SQL> insert into test1 values(1,1,1,1,1,1);
    1 row created.
    SQL> set timing on
    SQL> DECLARE
      2  CURSOR casecur IS
      3  SELECT  (CASE WHEN A1 IS NOT NULL THEN A1 END) AS A1
      4  ,       (CASE WHEN A1 IS NOT NULL THEN A2 END) AS A2
      5  ,       (CASE WHEN A1 IS NOT NULL THEN A3 END) AS A3
      6  ,       (CASE WHEN A2 IS NOT NULL THEN A4 END) AS A4
      7  ,       (CASE WHEN A2 IS NOT NULL THEN A5 END) AS A5
      8  ,       (CASE WHEN A2 IS NOT NULL THEN A6 END) AS A6
      9  FROM test1;
    10  BEGIN
    11    FOR i IN 1 .. 100000 LOOP
    12      FOR caserec IN casecur LOOP
    13        NULL;
    14      END LOOP;
    15    END LOOP;
    16  END;
    17  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:06.67
    SQL> DECLARE
      2  CURSOR casecur IS
      3  SELECT NVL2(a1, a1, NULL) a1, NVL2(a1, a2, NULL) a2, NVL2(a1, a3, NULL) a3,
      4         NVL2(a4, a4, NULL) a4, NVL2(a4, a5, NULL) a5, NVL2(a4, a6, NULL) a6
      5  FROM test1;
      6  BEGIN
      7    FOR i IN 1 .. 100000 LOOP
      8      FOR caserec IN casecur LOOP
      9        NULL;
    10      END LOOP;
    11    END LOOP;
    12  END;
    13  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:06.62
    SQL> I don't think it is going to much matter which you choose.

  • Checkbox Value in where condition of query

    Hi,
    I have a check box which shows values based on the LOV's . If i check on the checkbox the values that are selected on the check box must be used in the where condition to update the table.
    Please suggest me how to take the check box values.
    Am using the below methos to update but its not happening
    Declare
    old_cohort_name varchar2(500);           
    new_cohort_name varchar2(500);
    l_cohort_id apex_application_global.vc_arr2;
    begin
    l_cohort_id := apex_util.string_to_table(:P64_CASCADE_COHORT_NAMES);
    select cohort_name into old_cohort_name from study_cohort
    where cohort_id = :p64_cohort_id;
    select :P64_COHORT_NAME into new_cohort_name from dual;
    if old_cohort_name <> new_cohort_name then
    update study_cohort
    set      
    cohort_name = new_cohort_name
    where cohort_id = :p64_cohort_id and
    cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked
    End if;
    End;
    Please suggest me how to modify the code
    Tx
    Sudhri

    Hi Sudhri,
    where cohort_id = :p64_cohort_id and
    cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked If this is the code you are actually using, then the condition would only be met if l_cohort_id = :p64_cohort_id because you are using an AND condition over the same column in the where clause, so it will only return rows when both values are the same. Then, I think that it seems not to be working for you because :p64_cohort_id and l_cohort_id have different values, and no row is getting updated then. If the values you are selecting in your checkboxes are several ids of rows to update, besides the one with id :p64_cohort_id, then maybe the condition you need is something like this:
    WHERE cohort_id = :p64_cohort_id OR instr(l_cohort_id, cohort_id) != 0;Hope that helps.
    Regards,
    Sergio

Maybe you are looking for