Create new variable in a query using if

Is it possible to create a new variable in a query based on an if statement.
eg select A, B, C from table where condition
C is the new variable and should have a value of 10 if A is > 100 and a value of one if A > 100 and B < 200 for example.

Yes. Why not.
select a,
         b,
         case
             when a> 100 then
                10
             when a> 100 and b<200 then
               1
          end c
from table
where <condition>;Regards.
Satyaki De.

Similar Messages

  • Not able to create new e-mail on N8 using Mail for...

    Not able to create new e-mail on N8 using Mail for Exchange.
    Currently using google for my domain, but settings are the same as explained on the google Sync webpage: http://www.google.com/support/mobile/bin/answer.py?hl=en&answer=147951
    When creating reply on mail the application crashes.  When creating new mail it says "Kan bewerking niet uitvoeren" in english: "Unable to execute action".
    Any idea why creating mail is not possible?
    Regards,
    Joris

    problem is known
    more info there:
    /t5/Nseries-and-S60-Smartphones/N8-syncing-with-Google-contacts-amp-calendar/td-p/772020
    there is little workaround aslo.

  • How to create new Custom XML Report without using Form Builder

    Hi,
    What are the steps to create new Custom XML Report without using Report Builder ?
    Thanks and Regards,
    Abhi

    Hi,
    Steps we now follow
    1)Create Data Model in Reports Builder
    2)Create xml
    3)Insert xml in Publisher to build Fomat
    4)FTp rdf
    5)Create Data Definition and Template
    6)Create executable and Concurrent Program
    Is there any way we can build reports without use of Report Builder ? By writing PL SQL Package for Before Report and After Report etc ...
    Thanks and Regards,
    Abhijit Rode

  • Problem in creating new versions for existing DIR using CV01N

    I am working in SAP ERP 6.0 EHP 4.0 system.
    I have problem in creating new versions for existing DIR using CV01N
    I create a DIR version 00 with functional location and mpd cycles. Then when i try to create a new version by copying the contents created from already created document.I change the MPD cycles in the new version and save it.
    once when i display the first document created the mpdcycle specified in version 01 is copied to the 00 version.
    The document is inconsistent where versioning of document doesnot work properly wrt MPDCYCLE and MP HEADER.
    The problem which i found was the document identification guid remains the same for all the document versions getting created.
    The same is working fine in SAP ERP6.0 EHP3.0 sytem.
    Please someone help me in resolving the above issue.
    Regards,
    Prasad.B

    There is a change in the standard code.The reason for the above problem was  because of a missing Enhancemnet point in a standard function module 'CV110_DOC_CREATE_WITH_TEMPLATE'.
    IS-ADEC-MPD  - Enhancement to copy MPD data
    ENHANCEMENT-POINT CV110_DOC_CREATE_WTEMPL_01 SPOTS ES_SAPLCV110.
    +*$*$-Start: CV110_DOC_CREATE_WTEMPL_01----------------------------------------------------------$*$*+
    +**ENHANCEMENT 1  ZSF_AD_MPD_SAPLCV110.    "active version**+
    +*** copy MPD relevant data from templ. doc to current doc**+
      +**CALL FUNCTION 'MPD02_COPY_MPD_DATA'**+
        +**EXPORTING**+
          +**is_draw = ls_draw**+
        +**TABLES**+
          +**ct_drad = lt_drad.**+
    +*ENDENHANCEMENT.**$*$-End:   CV110_DOC_CREATE_WTEMPL_01----------------------------------------------------------$*$*+
    Created a custom enhancement point similar to SAP ECC6.0 EHP 3.0 system.
    The reason was the buffer was not getting cleared previously.After inserting the above code the DIR's are getting created withot any issues.
    Regards,
    Prasad.B

  • How to create snapshot portlet and snapshot query using server API

    How to create snapshot portlet and snapshot query using server API
    Regards
    Dheeraj

    Hi Sebastian,
    I have used the query and it is working fine. but, How could i include the headers of the query also in to the Excel Sheet.
    RehaanKhan. M
    see the method discussed here
    http://sqlblogcasts.com/blogs/madhivanan/archive/2008/10/10/export-to-excel-with-column-names.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to create a variable in Bex Query Designer

    Hi guys,
    I am writing a query for a travel management report using the SAP Standard cube. I would like to restrict the query so it only shows me the last two months excluding the current month. I have checked BI content in RSA1, but I canu2019t find a relevant SAP standard variable that I can use.
    Can anyone please tell me if I can create my own? And if so, how I can do this.
    Many Thanks
    Forhad.

    lets say u want to display following picture:
    sept$-----august$
    City
    -chicago123$--
    44$
    so in Query designer go to Default values section.
    Bring in Calendar month
    right click calendar month
    and hit Restrict
    now select variable
    use standard sap variable Current Month.
    hit okey
    now select Variable and hit Red button
    Result u restricted current month.
    in columns bring in keyfigure $
    right click and hit edit
    bring in time field calendar month
    right click and hit restrict
    bring in Current month
    right click and select - SET OFFSET FOR VARIABLE
    select -1
    hit okey
    repeat the above process
    and this time select offset = -2
    this way u restricted current month
    but displayed last 2 months for keyfigure values.

  • Infoset BI - not showing created on - variable in a query

    Hi
    I created an infoset based on two cubes, in one of the cubes used in the infoset - the Billing cube I have my document dates-created on (0createdon) infoobject.
    When I try to create a query reporting of the infoset, I can see the infoobject but not all the variables in the created on. At least 4 variables are missing from the Created on object.
    Any thoughts?

    Hi Michelle,
    If you have created four variables and selected all four variables and you still can't it all, it could be because the criteria of your variables are similar and the system ignore some of them. have you check the messages from the BEx status area? it is on the bottom left hand corner of your BEx.
    cheers.

  • IF NEW VARIABLE IN SQL QUERY, DISPLAYS AS LAST COLUMN + rpad not working

    Hello everybody and thank you in advance,
    1) if I add a new variable to my sql query to select a column which was already in the table, it shows it in the report table as the Last column to the right. That is, if I add "street" to
    something like city, postcode, street, store, manager, etc, instead of placing street between postcode and store, it places it as i said as the last column to the right.
    2) When values are entered into the cells of the tables, yes, they do expand it to their needed lenght, But, only if it is one word. If it is two, like when i enter the value "very good"
    then it takes two lines so as with a carriage return within the cell, thus, making it too high the row. I tried to padd spaces with rpad but it did not work. something like rpad(stock, 20,' ')
    I must say that the table is in the same page where there is a Form, so as the table grows in lenth it is actually squeezing the form located right on its left.
    3) rpad did not work with the most simple syntax, but less would with what i need because it turns out i am using DECODE in order to do a conversion between value displayed and
    value returned in my select list of values, something like : DECODE (TO_CHAR (stock),'1','Deficient','2','Average','3','Good','4','Very Good',null) AS stock,
    so, i have tried to put the rpad there in several places but either it gave parsing error or it left the column empty not picking any values.
    thank you very much
    Alvaro

    Alvaro
    1) That is standard behaviour of apex builder. You can change the display order with the arrows in the report attributes column report.
    2) You will have to play with the style attributes of the column to accomplice this. For instance style="white-space:pre;" in the Element Attributes of the column attributes. White-space:normal would thread several space (' ') as 1. So no matter how many you add with rpad they will be shown as 1.
    Or set a width either as attibute or in a style class for that column.
    Nicolette

  • Create New Variable for COPA Drilldown Reports in KE3E

    Hi,
    How can we create a formula variable for COPA Drill down reports in KE3E? In standard global variables formula variable is not avaiable, I need to create a formula variables like ...from period, to period, last fiscal year and next fiscal year..
    While creating report in KE31/KE35 trying create local variables, but it doesn't.
    Can any body advise how can we create a new variables for  "from period, to period, last fiscal year and next fiscal year.."
    Thanks
    VS Rao

    Hi Rao
    For Period (From &To)
    1. KE3E
    2. Type of Var = Char Value
        Enter variable name, say, ZPERIOD
        Field Name = PERDE
        Replacement type = Entry
        Enter Description
        Parameter/selectop = Selection Option
    For Fiscal Year
        Type of Var = Char Value
        Enter variable name, say, ZGJAHR
        Field Name = GJAHR
        Replacement type = Entry
        Enter Description
        Parameter/selectop = Parameter
    For Next and Last Fiscal Year
    When you define your form in KE34/KE35
    Use the variable ZGJAHR in your report
    In the column for Next Year, Enter "ZGJAHR+1" as the local variable for GJAHR
    In the Column for Last year, Enter  "ZGJAHR-1" as the local variable for GJAHR
    Regards
    Ajay M

  • Creating new Variables/objects in OLAP Universe

    Hi,
    We are currently using BOXI 3.1 Sp2. We have defined BEX queries on which Universes have been generated (using MDX).
    We are then creating WEBI reports using these Unvierses. We are not able to add variables/objects at universe level as the XML tags do not parse. We are on FP 1.4. Is there any solution to this, or is it a Bug?

    Hi Ingo,
    Thanks for the reply.
    I did go thru the document you provided and did accordingly.
    But still the syntax does not parse. In some cases, it does parse, but does not do the required filter.
    Not sure what the issue is.
    We would also like to create new objects/variables using If then else formula and other Characteristics.
    For example, If company=XYZ then Measure-1000 else Measure.
    But we get syntax error. It appears that only measures can be used in an If-then-else logic, which is absurd.
    We have contacted SAP support on this, but they have not come back with a proper reply yet.

  • How to create a variable, and how to use the same across all the reports?

    Hi,
    Is there any possibility of creating a variable at once and making use of that across in all the Crystal Reports?
    Thanks In advance for your time and solution.

    MohanMRK,
    can you describe how you get the value for this variable?
    is it calculated on one report and then you want to pass it to a 2nd report? if that's the case, what you can do is have the reports linked via an opendocument link and pass the value to the 2nd report as a parameter. the value / parameter is only shared when you press the opendocument hyperlink.
    please see the sdk library [here |http://www.sdn.sap.com/irj/boc/sdklibrary]and scroll down to the opendocument section near the bottom.
    if you are just trying to find a way to share a calculation across reports look into creating a Custom Function which can be added to your repository. please note that this will not pass a calculated value across 2 or more reports, but will just have a shared method of making the calculation.
    as Abhilash mentioned before, there's no way to use an actual Variable across 2 separate reports without them being a main report and subreport(s). in that case you'll want to look into Shared Variables.
    cheers,
    jamie

  • How to create Text Variables in BEx Query Designer

    How  can i create Text Variables in Bex Q.D.
    I am able to create characteristic variables
    but i can't find option to create text variables.
    What's the requirement to create Text variables in Bex Q.D.
    When i try to create Text variable for 0calDay.. the variable type is characteristic by Default and disabled.
    How can i create text variables related to 0CalDay with which i need to work in Customer Exit.

    Hi,
    You have to create characteristic variable processing by Customer Exit by considering 0CalDay as a Reference Characteristic
    After creation of the above variable, you restrict your KF with the above created variable.
    Now you can create a Text variable for the description of your KF. This way it works...........
    Regards,
    Suman

  • EAS 9.3.1 Can't choose planning outline when creating new variable

    I need to develop a new business rule for production but I can't choose a planning outline for my new variable. Nothing shows up under planning. I can see the prod planning server in prod, but I can't see the dev planning server in dev. Does anyone know how to fix this? I just recycled and there was no change.
    Thanks

    Once you have restarted eas, planning services, make sure you log into the planning application first, then open EAS and try again.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Automatically create new Excel file from template using data from a selected row in a separate Excel file

    I am fairly new to Macro and VBA in Excel. I am trying to reduce the amount of work involved in a task that is performed often in our office. Currently, the task involves using 2 separate Excel files. One file is a tracking sheet and the second is the document
    that gets sent out to the client. The second document has all the same information that is inserted into the tracking sheet. What I would like to do is have the information that is in one row on the tracking sheet populate into a new excel file that is created
    automatically from an existing template.
    I have been able to make this partially work. What I have been able to achieve is have the cell that is selected in the tracking sheet (the description field) copy into the new file that is created from the template that is on our server.
    Sub NewRFI()
    ' NewRFI Macro
        MsgBox Selection.Address(ReferenceStyle:=xlA1, _
                               RowAbsolute:=False, ColumnAbsolute:=False)
        Selection.Copy
        Workbooks.Add Template:= _
            "template file path goes here"
        Range("C14").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
        Range("C14").Select
        Application.CutCopyMode = False
    End Sub
    What I need to do is get the rest of the information from that same row in the tracking sheet to copy to the new file as well. The other information includes the document number (one cell to the left of the selected cell), who it is from (one cell to the
    right of the selected cell), and the date (two cells to the right of the selected cell). As stated, this information is all in the same row on the tracking sheet. Each piece of information needs to be copied to a certain cell in the new file and I do not want
    the source formatting to be copied to the new file.
    Ideally, I would like it to operate like so: select the first cell in the row (in this case would be the document number field). Then click a button to run the macro that will then copy the information from that row in the tracking sheet to specific cells
    in the new file that is created from the template.
    This process will save us from having to either manually copy and paste the information into the new file or re-type the same information that is already in the tracking sheet.
    This is probably a simple thing to do but it would be great if anybody had some insight on this issue. Thanks in advance!

    Try code like the following. You will have to change the target cells (D25, F1 and H4) to the ones you want, I just used some arbitrary cells as example.
    Sub NewRFI()
    Dim rngCell As Range
    Set rngCell = ActiveCell
    MsgBox Selection.Address(ReferenceStyle:=xlA1, _
    RowAbsolute:=False, ColumnAbsolute:=False)
    Workbooks.Add Template:="template file path goes here"
    Range("C14").Value = rngCell.Value
    ' Change the target cells as needed
    Range("D25").Value = rngCell.Offset(0, -1).Value
    Range("F1").Value = rngCell.Offset(0, 1).Value
    Range("H4").Value = rngCell.Offset(0, 2).Value
    End Sub
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Creating new Tablespace in 10g XE using Database Home Page

    How can I add a Tablespace using the "Database home Page" GUI? I've done this before, but now do not see a link for "Create Tablespace" under the Administration -> Storage icon. I'm logged in as sys.

    use sqlplus to create a new tablespace
    (set your XE environment first)
    (for Linux)
    the environment file envOraXEclient for example) -- modify for your env and different shell, and source the file
    export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
    export TNS_ADMIN=/home/mytnsdirectory
    export TWO_TASK=XE
    export LD_LIBRARY_PATH=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib
    export PATH=$ORACLE_HOME/bin:${PATH}
    by using sqlplus, create the tablespace (use different size if you want, up to 4gb, you can create smaller, more than one tablespace, etc - this is just an example)
    CREATE SMALLFILE
    TABLESPACE "MYTBLSPC1"
    DATAFILE '/usr/lib/oracle/xe/oradata/XE/mytblspc1.dbf'
    SIZE 2G REUSE AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
    LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
    if you want, create a dedicated temporary tablespace for your user/s as well (here is an example)
    CREATE SMALLFILE TEMPORARY TABLESPACE "MYTEMP"
    TEMPFILE '/usr/lib/oracle/xe/oradata/XE/mytemp.dbf'
    SIZE 100M REUSE EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1024K
    turn the recyclebin off if you want/need to (I do ;)
    alter system set recyclebin=off;
    change the open_cursors if you want/need to (I do ;)
    ALTER SYSTEM SET open_cursors = 5000 SCOPE=MEMORY;
    ALTER SYSTEM SET open_cursors = 5000 SCOPE=SPFILE;
    ALTER SYSTEM SET session_cached_cursors = 50 SCOPE=SPFILE;
    create a specific user utilizing the tablespaces you created earlier
    CREATE USER "ZAFER" PROFILE "DEFAULT"
    IDENTIFIED BY "zafer" DEFAULT TABLESPACE "MYTBLSPC1"
    TEMPORARY TABLESPACE "MYTEMP"
    ACCOUNT UNLOCK;
    (grants are up to you - and your development / deployment environment)
    GRANT UNLIMITED TABLESPACE TO "ZAFER";
    GRANT "CONNECT" TO "ZAFER";
    GRANT "RESOURCE" TO "ZAFER";
    Edited by: zaferaktan on Sep 4, 2009 10:09 AM

Maybe you are looking for