Conditions in the query

Hi friends,
Need a help from you to build a query from query designer. Here is my scenario, I have a date1,date2 and date3 objects. I need check whether date1 is in between date2 and date3 or not in query level.
Your help is really apreaciated.
-BK

Create a formula and you will see several operators. As said earlier, you can use boolean operators or also If Else statement can be used to pass the desired values.
Regards
Pankaj

Similar Messages

  • Condition in the query

    Hello Guyz,
    I have a scenario where I have to filter values of one text characteristic based on the other text characteristic.
    i.e
    I have text char whose values are either yes or no and there is a date characteristic.
    As per the requirement when the value is yes in the report date values should be reflected but when the value is no date value should be blank.
    note in the target the date values are present for both yes and no .
    Contract                Date 
    Yes                      01/10/2009
    No                         #
    Regards,
    Ravi

    Hi Ravi,
    I have two options
    1) Add a new date field in the source itself and map it with date and char . And write a field routine to say if it is yes then date or else blank. This is straight forward and easy but requires a ful load once again . If possible this is easy.
    2) This is at report level and it is lenghty and i  think it is possible but you will get date in key figure instead of in another characteristic but has some pre requireties.
    a) You should have those two charactertistcs in report display.
    b) The date output will be a key figure not a characterisitc and cant be only kept after charcterisitcs in report.
    How to achieve this
    1) Create a formula variable FV1 and use replacement path of characteristic . Then create a formula F1 which uses this formula variable. Then in the formula if this formula variable is 'YES' then 1 or else it is 0.
    2) Create another formula varaible FV2 and use replacement path of date.  Then create another formula F2 and use if F1 = 1 then FV2 .
    This will display date if characteristic is yes but in key figure.
    I am sure you can implement 2 point but only point i am doubtful is whether FV1 will return yes or not.
    But please give a try.
    The problem is complex because based on one characteristic to get another one is dificult at report level because we can limited flexibilty at query only restricted key figure ( selection ) and calculated key figure (formula) which uses onyl key figures and returns another key figure but not characteristic.
    Hope you got the second option.
    Thanks
    Vamsi

  • Hot to put conditions in the query.(Very very urgent )

    Hi BW Gurus,
    Pls give me a solution for this one i have to give it today only the report pls consider this as urgent.
    new BW report, following is an explanation of the report requirement  what the report would look like.
    The logic of the report is to retrieve all chargebacks based on certain Selection Criteria entered by the user.
    Selection Criteria are as follows:
    Company Code
    Posting Key - this should not be a value entered by the user
    Customer
    Reason Code
    There should also be a selection parameter available to the user to specify the report type. The selection list should be as follows:
    Top 3
    Top 5
    Top 10
    Top 15
    Top 20
    Top 25
    Each of the above may be viewed as a report variant. This selection parameter basically specifies the number of customers to be displayed, e.g. Top 3 means that the top 3 customers from a chargeback total perspective should be displayed.
    The report should display by Customer by Reason Code the value of the Chargeback. A total for Chargebacks should be calculated per reason code, per customer and a total for the report
    The report should also provide drill down capability in that the user should be given the ability to drill down by customer by reason code to display all chargeback line items that make up the total for that reason code for that customer.
    Thanks in advance.

    My pleasure Arun!! Actually I was on BEx screen.. so I cud see that varible entry on hand..
    Yeah..you are right.I think this is more on drilling down...,
    I think,
    One requrement looks like demanding Reason code, Customer sequence and Other demanding Customer and Reason code sequence..
    Hold on for experts comments..
    Venu,
    I sugget put everything in Navigational and place only 'Company' code in the rows.. and ask user to drill down in the sequence..
    regards,
    Hari

  • Multiple Conditions in a Query

    Hi,
    I have one Characteristic and 3 KeyFigures (mentioned below in quotes) in a Query and I would like to have following Conditions built in the query:
    1. Top N Condition on "Net Sales"
    2. Only display "Costs" > 0
    3. Only display "Quantities" > 10
    For some reason, it is not working as desired whether I combine them in one Condition or create 3 different Conditions in the Query. Does anyone have any idea?
    Thanks
    Srini

    Hi Srini,
    What exactly is wrong?
    In case of three separate conditions try to activate the 1st one, then the 2nd one, and finally - the 3rd one.
    If on one of these steps you'll get a message about non applicability, then your conditions conflict with each other.
    See examples of using conditions here:
    http://help.sap.com/saphelp_nw04s/helpdata/en/0b/f584409db95537e10000000a1550b0/frameset.htm
    Best regards,
    Eugene

  • Condition in the report!!! URGENT

    Hi Gurus,
              I am filtering a charectaristic in the report by A, B, C and D. If the characteristic type is A or B, then, the key figure has to be negative.How to achieve this using conditions in the report????
    I already tried using conditions in the query, but it doesnt work. Is there any possibilities using Formula variable or replacement path variable???if so, how can I do that???
    Any Help appreciated with points.
    Regards,
    PNK
    Edited by: pnk on Mar 27, 2008 6:17 PM

    Hi PNK,
    Create a restricted key figure based on your key figure restricting the characteristics tO A and B.
    Hide this restricted key figure in display properties.
    Based on this restricted key figure create a formula multiplying the same by (-1).
    Hope this helps,
    Ajay

  • Pls help me to modify the query for performance improvement

    Hi,
    I have the below initialization
    DECLARE @Active bit =1 ;
    Declare @id int
    SELECT @Active=CASE WHEN id=@id and [Rank] ='Good' then 0 else 1 END  FROM dbo.Students
    I have to change this query in such a way that the conditions id=@id and [Rank] ='Good' should go to the where condition of the query. In that case, how can i use Case statement to retrieve 1 or 0? Can you please help me to modify this initialization?

    I dont understand your query...May be below? or provide us sample data and your output...
    SELECT *  FROM dbo.students
    where @Active=CASE
    WHEN id=@id and rank ='Good' then 0 else 1 END
    But, I doubt you will have performance improvement here?
    Do you have index on id?
    If you are looking for getting the data for @ID with rank ='Good' then use the below:Make sure, you have index on id,rank combination.
    SELECT *  FROM dbo.students
    where  id=@id
    and rank ='Good' 

  • Broadcasting the query

    Hi,
    There is a condition in the query. When it is executed in BEx, the report is correct.
    But, when it is broadcasted, the condition isnot taken into consideration and the report isnot correct.
    How to fix this issue?
    Thanks.

    Hello,
    Try this note:  1243621 -  Conditions in BEx Broadcasting are inactive
    If persist, let me know your BW version (SAPKW70?0??)
    Thank you.
    Edward John

  • Control the query of Content By Search web part or a Catalog-Item Reuse web part from JavaScript

    Is it possible/supported to intercept and change the query before it gets issued by a Content By Search or Catalog-Item Reuse webpart?
    I am writing a multilingual site utilizing cross-site publishing mechanism, and the out-of-box (OOB) web parts would perfectly work if not for the following requirement that I've got: I need to serve location-specific content to the end user. I have several
    versions of each content page for each geographical location, and I have tagged the pages accordingly with managed metadata keywords. I also can deduce the user's location from her browser's IP address and store it in a JavaScript variable. It is here
    where I am getting stuck: I am trying to change on the fly the queries the web parts issue in order to attach the information about the user's geographical location, unsuccessfully so far.
    I cannot rely on server-side code unless it is a cloud-hosted app code. I am about to give up and consider a custom solution alternative instead, which would be relying on Search REST API and custom client-side scripted widgets in place
    of the OOB search web parts. This seems like an expensive alternative as the entire site could have been built using the OOB web parts, if not for the location requirement.
    I would appreciate any suggestions.
    Thanks in advance,
    Ivan.

    hi
    I would check several directions:
    - in query transformation you may add keyword filter "Value of a field on the page". Documentation doesn't clearly says what "field" means here: is it only for site columns, or also may work for UI controls on the page. In second case it would solve your
    problem (it would be possible to add hidden field on the page and set value via javascript). But chances that it works like this are not high;
    - in the query settings of the Content by search web part there is setting "Loading behavior": Choose whether this query is issued on the server while the page is loading, which is better for your main content, or from the browser after the page appears.
    I.e. if you will choose 2nd option there will be a chance to intercept the query on the client side in theory. All of this requires experimenting of course;
    - by default Content by search web part sends query to /_vti_bin/client.svc/ProcessQuery with http post from client side (you may check it in fiddler). You may try to find the exact javascript function which performs the call and override it by adding additional
    conditions to the query (fortunately it is not complicated in javascript).
    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

  • List of conditions in the context menu

    Hello,
    If I define conditions in the query designer I had these conditions available in the context menu while executing a query both in excel and in web within BW 3.5.
    Within NW04s I miss the conditions in the context menu. The only way I know how to make conditions available during the execution of a query is to build in a list of queries item on the work sheet itself by using the design tool.
    Is this really the only way? The context menu was rather convenient either.
    Thank you.
    Ingo Peter

    Hi Ingo,
    Please refer the link below
    http://help.sap.com/saphelp_nw2004s/helpdata/en/5b/8c3842bb58f83ae10000000a1550b0/frameset.htm
    Regards
    Sajeed

  • How Can I Change the  Where Condition In the First SQL Query?

    SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT,
    TRUNC(MONTHS_BETWEEN((TO_DATE('19'||END_SVC_DT,'YYYYMMDD')),BEG_SVC_DT)/12),
    mod(trunc(months_between((to_date('19'||end_svc_dt,'YYYYMMDD')),BEG_SVC_DT)),12),
    DECODE((SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1),-1,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -2,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -3,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -4,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -5,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -6,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -7,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -8,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -9,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -10,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -11,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -12,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -13,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -14,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -15,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -16,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -17,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -18,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -19,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -20,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -21,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -22,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -23,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -24,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -25,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -26,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -27,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -28,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -29,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -30,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    -31,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
    30,0,
    (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1))
    FROM SVC_OCCURRENCES
    WHERE end_svc_dt not in ('PRESENT')
    AND SUBSTR(END_SVC_DT,1,1) IN '9'
    AND SUBSTR(END_SVC_DT,5,2) NOT IN ('31')
    and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
    UNION
    SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT, NULL, NULL, NULL
    FROM SVC_OCCURRENCES
    WHERE SUBSTR(END_SVC_DT,1,1) IN 'P'
    The above code works fine and I get the correct numeric values from the SQL
    query when the varchar2 end_svc_dt field is numeric however if I have encoded
    the word 'PRESENT' in the varchar2 end_svc dt field the SQL query aborts at
    the last statement in the WHERE condition. The beg_svc_dt field is a Date field.
    and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
    I get the following error message
    ERROR ORA-0722 INVALID NUMBER
    I encode the word 'PRESENT' in a varchar2 end_svc_dt field on an Oracle form. This is the only word that can be encoded.
    Is there some way that I can bypass the last statement in the where condition and
    compute the values from the SQL query without having the SQL query abort?
    Eventually I want to do this in a report. I know that this sounds strange but can it be done?

    The above code works fine and I get the correct
    numeric values from the SQL
    query when the varchar2 end_svc_dt field is numeric
    however if I have encoded
    the word 'PRESENT' in the varchar2 end_svc dt field
    the SQL query aborts at
    the last statement in the WHERE condition.Ouch!
    Storting dates in VARCHAR2 columns is bad practice, poor design and makes for horrible code.
    The beg_svc_dt field is a Date field.
    and (SUBSTR(END_SVC_DT,5,2) -
    SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')If it's a date field then why on earth are you trying to SUBSTR it. SUBSTR = sub-string i.e. take a sub section of a string not sub-date.
    I get the following error message
    ERROR ORA-0722 INVALID NUMBERAnd you're surprised by this?
    Is there some way that I can bypass the last
    statement in the where condition and
    compute the values from the SQL query without having
    the SQL query abort?Store your dates properly, use additional flag columns for non-date information and code your SQL properly.
    Eventually I want to do this in a report. I know
    that this sounds strange but can it be done?Yes, most things are possible.

  • Problem to get ResultSet when it is used a Date type in the query condition

    hello ,
    I having a bit of nightmare getting a ResultSet how result of one simple Query for a table when the condition WHERE involve a Date type.
    To change the String value in a date to use in the query condition, I tried both:
    String strDate = "dd/mm/yyyy";
    (1.) java.sql.Date sqlDate = new java.sql.Date(strDate.getTime() )
    (2.) SimpleDateFormat formatter = new SimpleDateFormat(strDate) ; sqlDate = formatter.parse(strDate);
    and finally I use this code to get the ResultSet:
    sql = "SELECT * FROM myTable Where (idCli = " + cd_Cli + " And dateReg = " + sqlDate + ")";
    statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    resultSet = statement.executeQuery(sql);
    boolean ok = resultSet.last();
    totNumberOfRegistration = resultSet.getRow();
    But In both the cases I get a empty resultSet.
    I shoul like if someone would look my code to say me where it is the mistake...
    thank you
    tonyMrsangelo
    P.S. I tryed using PrepareStatement too to get the ResultSet, but in that case I couldn't use the ResultSet because executing the statement resultSet.last() I get the error: "Result set type is TYPE_FORWARD_ONLY"

    In a database like Oracle, you need to use a function like TO_DATE; other databases may have something similar.
    However, the proper way to do this is to use a PreparedStatement. Then you can say
    PreparedStatement ps = conn.prepareStatement("update SOMETABLE set SOME_DATE=? where SOME_ID=?");
    ps.setDate(1, new java.sql.Date(someJavaUtilDate.getTime()));
    ps.setInt(2, theId);
    ps.executeUpdate();

  • Two conditions in where part of the query out of which 1 is based on length

    hi
    am having two tables and i need to join them to get my desired output. let me explain with example
    table A contains data like
    >
    col1 col2 col3
    12345 sons abcd
    23456 snms bcde
    34567 snms nil
    56478 sons ..
    >
    table B contains data like
    >
    col-1 col-2 col-3
    sons not-subscribed 0
    sons nil-balance 111
    snms not-subscribed 0
    snms incorrect 111
    soai incorrect 111
    >
    i need the output like
    >
    col1_of_table_A col3_of_table_A col-2_of_table_B
    12345 abcd nilbalance
    23456 bcde incorrect
    34567 nil not-subscribed
    56478 .. not-subscribed
    >
    likely requirement in sample query format is
    select a.col1,a.col3,b.col-2 from A a, B b where ((a.col2=b.col-1 and length(a.col3)>length(b.col-3)) or (a.col2=b.col-1 and length(a.col3)<length(b.col-3)))how to achieve this conditional joint?

    Hi,
    in your query i just added '..' instead of null for the row starting with 56478 in table A and executed the query as below and it doesn't give my desired output.
    with a  as
         select 12345 as col1, 'sons' as col2, 'abcd' as col3 from dual union all
        select 23456, 'snms', 'bcde' from dual union all
        select 34567, 'snms', 'nil' from dual union all
      select 56478, 'sons', '..' from dual
       , b as
         select 'sons' col1, 'not-subscribed' col2, 0 col3 from dual union all
        select 'sons', 'nil-balance', 111 from dual union all
         select 'snms', 'not-subscribed', 0 from dual union all
        select 'snms', 'incorrect', 111 from dual union all
        select 'soai', 'incorrect', 111 from dual
       select  col1, col3, col2
      from
           select a.col1,a.col3,b.col2, row_number() over (partition by a.col1 order by b.col2) rn
            from A a
             left outer join b on (
                                  (    a.col2         = b.col1
                                   and  length(a.col3) > length(b.col3)
                                  or
                                   (    a.col2         = b.col1
                                   and length(a.col3)  < length(b.col3)
      where rn = 1
      output is
    >
    COL1     COL3     COL2
    12345     abcd     nil-balance
    23456     bcde     incorrect
    34567     nil     not-subscribed
    56478     ..     nil-balance
    >
    what could be problem?

  • How to define the query condition of Image Theme in MapBuilder?

    Hi,
    I'm trying to add an dynamic Image Theme in OracleMap, but there's a problem.I defined the query condition of Image Theme like this:
    select scanimage,shap from image where scanimgid=467
    The shap column is the MBR column
    And the XML CODE:
    <?xml version="1.0" standalone="yes"?>
    <styling_rules theme_type="image" image_column="SCANIMAGE" image_format="JPEG" image_unit="M" image_resolution="1.0">
    <rule>
    <features> select scanimage,shap from image where scanimgid=467 </features>
    </rule>
    </styling_rules>
    When i preview this Image Theme ,there is an ORA-00936 error means lack of expression.
    Is there any problem with my definition?Or can query an image from an Image Theme?
    Thanks a lot for your help!
    Message was edited by:
    N.Mars
    null

    Hi Mars,
    predefined image theme definition does not support a "select" statement in the <features> tag. You should just define a query condition in the <features> tag.
    It seems that you are trying to use an image theme in Oracle Maps, but it currently does not support a FOI image theme. You should add a predefined image theme as part of the basemap, and maybe add scales values to set the visibility range of this image theme.
    Joao

  • URGENT: To change the where condition in select query at runtime ?

    Hi,
    I have to develop a report, 4 which I have created a selection screen with 7 Input Parameters whose value is to be filled by the user while executing the report.
    On the basis of this I do the desired selection of output.
    But the problem is that how do I write my select Query(where condition) if the user enetrs only 2 Input parameters or 3 or whatever he feels like.
    Pls help me out...

    hi,
    check this sample code.
    Here i am populating where condition at runtime.
    DATA: V_WHERE TYPE STRING.
    SELECTION-SCREEN BEGIN OF BLOCK INPUT WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN,
                     S_ERDAT FOR VBAK-ERDAT.
    SELECTION-SCREEN END OF BLOCK INPUT.
    START-OF-SELECTION.
      PERFORM POPULATE_WHERE.
      PERFORM GET_VBAK_DATA.
    *&      Form  POPULATE_WHERE
    *       Populate Where
    FORM POPULATE_WHERE .
      IF NOT S_ERDAT[] IS INITIAL.
        CONCATENATE 'VBELN IN S_VBELN'
                    'AND'
                    'ERDAT IN S_ERDAT'
              INTO V_WHERE
              SEPARATED BY SPACE.
      ELSE.
        V_WHERE = 'VBELN IN S_VBELN'.
      ENDIF.
    ENDFORM.                    " POPULATE_WHERE
    *&      Form  GET_VBAK_DATA
    *       GET VBAK DATA
    FORM GET_VBAK_DATA .
      SELECT VBELN
             ERDAT
             VBTYP
             NETWR
             WAERK
             VKORG
             VTWEG
             SPART
        INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
        FROM VBAK
        WHERE VBELN IN S_VBELN
        AND   ERDAT IN S_ERDAT.
       WHERE (V_WHERE).
    endform.
    Regards
    Sailaja.

  • I need use conditions in the select fields of a query.

    Hello,
    Is possible, that I can have conditions in the select fields of a query? In a invoice when the type is cancellation I want to put *-1 to price and if is other type the price is normally.
    If VBRK.FKART = 'S1' THEN KWERT*-1 else KWERT .
    Thank you very much.

    you can do two things:
    1. select the data into internal table and loop through the internal table and do the necessary changes
    SELECT fkart kwert
    FROM vbrk
    INTO TABLE itab
    WHERE ...
    LOOP AT itab.
    IF itab-fkart EQ 'S1'.
    itab-kwert = itab-kwert * -1 .
    MODIFY itab.
    ENDIF.
    ENDLOOP.
    2. use select-endselect and change the data acc. to your needs inbetween and append the internal table.
    SELECT fkart kwert
    FROM vbrk
    INTO wa
    WHERE ...
    IF wa-fkart EQ 'S1'.
    wa-kwert = wa-kwert * -1 .
    ENDIF.
    APPEND wa TO itab.
    ENDSELECT.
    (The first approach is probably faster.)

Maybe you are looking for