Multiple condition check using decode

HI All,
I have a new requirement and need your help .
need to check the follwing condidtions in a sql statement.
a) we have a status coulmn which has values like 1,2,3,4,5,6,7 based on some other coulmns . this status will keep on repeat based on values in other coulmns.
each status will update one by one. ( ie, update of status1 to status2 takes 3 min of time ) and status4 to status5 takes 10 min of time.
i need to select the rows which exceeds the above time limit.
ie )
if Time taken for (status1 to status2) change is > 3min then select that row.
and if Time taken for (status14 to status5) change is > 10min then select that row.

the query will run on every 10 min,and if any of the status not changed ,
ie )
for eg), trunc( (sysdate-modifieddate)*24*60 ) > 15, we need to select those rows.
Below shows example of the data . , if you see the record3 ( which in status2)
if modidifeddate <sysdate by 15 min , that record need to be selected.
its applicable for other status also . Plz help me
paytrxkey     Groupid          Payref     status     Modifieddate
15198595     GHK02793     Q0003119     1 12/6/2006 8:49
15198673     GHK02793     Q0003120     1 12/6/2006 8:49
15275420     GSG00764     Q0007162     2 12/6/2006 8:49
15275421     GSG00764     Q0007163     1 12/6/2006 8:49
15275425     GSG00764     Q0007167     2 12/6/2006 8:49
15275427     GSG00764     Q0007169     1 12/6/2006 8:49
15310160     GHK04571     Q0000138     3 12/6/2006 9:00
15275426     GSG00764     Q0007168     1 12/6/2006 9:02
15275424     GSG00764     Q0007166     4 12/6/2006 9:02
15275423     GSG00764     Q0007165     1 12/6/2006 9:02
15275422     GSG00764     Q0007164     4 12/6/2006 9:02
15404354     GAE00099     Q0014834     1 12/6/2006 9:06

Similar Messages

  • Multiple condition check using if statement.

    Hi
    i NEED to check two conditions using if statment. I was wondering whether it is possible.
    say fields zx and zy in an internal table itab. if one of those is intiial i have to display a message.
    i tried this way
    if itab-zx or itab-zy is initial.
    error message.
    endif.
    It gives me error in syntax check.
    I think i can check for first field using if and second one with elseif but for that matter of fact i have like 10 fields .out of which even one is initial i have to throw a message saying 'DATA CANNOT BE SAVED'.
    Please suggest me how to go about this.
    Thanks in advance.

    Hi Swathi,
    You have to loop your internal table and then check.
    Try this code.
    LOOP AT itab.
      IF itab-z1 IS INITIAL OR
         itab-z2 IS INITIAL OR
         itab-z3 IS INITIAL OR
         itab-z4 IS INITIAL OR
         itab-z5 IS INITIAL OR
         itab-z6 IS INITIAL OR
         itab-z7 IS INITIAL OR
         itab-z8 IS INITIAL OR
         itab-z9 IS INITIAL OR
         itab-z10 IS INITIAL.
        MESSAGE 'DATA CANNOT BE SAVED' TYPE 'E'.
      ELSE.
        " Processing if none of the fields are Initial
      ENDIF.
    ENDLOOP.
    Regards,
    Arun Sambargi.

  • Multiple condition checking question

    Hi I have a newbie question -
    if ((temp == null) && (!temp.text.equals(""))) {
    statement;
    If temp really is null, would this give a compiler error? or would it simply break after the first condition?
    Thanks,
    Mike

    whatsupdoc wrote:
    Hi I have a newbie question -
    if ((temp == null) && (!temp.text.equals(""))) {
    statement;
    If temp really is null, would this give a compiler error?Compile it and see.
    I'm curious though what you're trying to accomplish. You seem to be confused about the meaning of &&.
    or would it simply break after the first condition?&& and || are "short-circuit" operators. They stop evaluating once the truth of the operation is known. So if the first operand to && is false, it stops there and does not evaluate the second, since the result of the && must be false, regardless of what the second operand is. Likewise, if the first operand to || is true, then it doesn't evaluate the second one, because the result is true regardless.

  • Condition checking using the user input

    hi all,
    i am taking input from the user and the input is the employeeid,starttime and endtime with in the report. then i want to display the columns of some table based on these inputs. my require ment is the data realted to that employeeid and the information of that columns between the starttime and endtime must be extracted.
    SELECT ALL TASK_ENTRY.TDATE,
    TASK_ENTRY.T_TASK, TASK_ENTRY.SUB_TASK, TASK_ENTRY.TASK_STATUS
    FROM TASK_ENTRY WHERE TASK_ENTRY.EMPID LIKE :EMPLOYEEID AND
    TASK_ENTRY.START_TIME<= :STARTTIME AND TASK_ENTRY.END_TIME >= :ENDTIME
    can any body clarify whether the query is right or not. if not please give me the right query.
    i have written the code for bringing the data of that particular employee but i am unable to bring the data between those dates. the query what i have written is as above. can any body rectify my query.

    ANDTASK_ENTRY.START_TIME>= :STARTTIME AND TASK_ENTRY.END_TIME >= :ENDTIME
    I think here is problem.
    You must reverse it. as
    AND
    TASK_ENTRY.START_TIME >= :STARTTIME
    AND
    TASK_ENTRY.END_TIME <= :ENDTIME
    Capri...

  • Need Help on using xdoxslt:ifelse multiple conditions

    Hi Experts
    I have a requirement with multiple conditions and not able to get this working e.g. if possible how to get the variable if condition then get_variable
    <?xdofx: if Group='X' and Price!=0 and ItemId='' then (xdoxslt:get_variable($_XDOCTX,'Price'), ' ')
    else if Group='Y' and ItemId!='' then 'Included'
    else if Group='Z' and ItemId!='' then 'Included' else '' end if?>
    Also I tried using xdoxslt:ifelse
    <?xdoxslt:ifelse((Group='X' and (Price)!=0 and ItemId=''),
    (xdoxslt:ifelse((Group='Y' and ItemId=''),Include,' ')),(xdoxslt:get_variable($_XDOCTX, 'Price'))?>
    Please help it is very critical
    Thanks

    Can you please explain a bit as to what you are trying to achieve?
    for example: if Group = X and Price <>0 and ItemID is null then what are you trying to do?
    You can use choose statements for your scenario.
    Example:
    <?choose:?>
    <?when:ReportStatus='Approved' ?>
    <?'Approved'?> <?end when?>
    <?when:ReportStatus = 'Closed'?>
    <?....?>
    <?otherwise:?>
    <?....?>
    <?end otherwise?>
    <?end choose?>
    Thanks,
    Bipuser

  • Deleting data from another table with multiple conditions

    Hi frnds
    I need to delete some data from a table based on multiple condition I tried following sql but its deleteing some rows which is not meeting the criteria which is really dangerours. When i trying = operator it returns ORa- 01427 single -row subquery returns more than one row
    delete from GL_TXNS
    where TRN_DT in (Select trn_Dt from GL_MAT)
    and BR in (select ac_branch from GL_MAT)
    and CODE in (select CODE T from GL_MAT)
    and (lcy_amt in (select lcy_amt from GL_MAT) or
    fcy_amt in(select fcy_amt from GL_MAT)
    rgds
    ramya

    My answer is the same as Avinash's but I will explain a little bit more.
    ORa- 01427 single -row subquery returns more than one rowmeans that you have a subquery that Oracle is expecting one value from that is returning multiple values. In your case you need one value for the equijoin ("=") and you are getting more than one value back. The error happens even if all the values are the same - multiple values being returned will cause the error.
    The solution is to either allow multiple values to be returned (say, use the IN condition istead of "=") or only return one value if possible (say, forcing one value by using DISTINCT, GROUP BY, or a WHERE clause condition of ROWNUM=1) - but these workarounds must be checked carefully to make sure they work correctkly

  • Mail step should be sent to all the users in multiple condition

    hi experts,
                      I have a requirement on invoice posting.Say if invoice amount is 1000 then person A can post the invoice.
    if >= 1000 person B can post the invoice.
    If >=2000 person C can post the invoice.
                                                                      what i have did is, created a multiple condition and then based on the inv amount assigned 3 methods for invoice posting.My problem is if a person posts an invoice amount of 1000.A mail has to be sent to Person B and C informing that an amount of 1000 is posted with user id.Same for person B, ie mail should be sent to person A and C informing regarding invoice posting.Now inside the multiple condition i cannot assign mail step.Coz based on the condition it will go to a particular user for invoice posting but where as mail should be sent to all the users.So how can i achieve this??.

    Hi Priyanka,
    I am getting 1 thing why you need need multiple conditions. No need to create any multiple conditions.
    1. Create a rule using transaction PFAC. (you can use the example as Rule: 0000168).
        a. Create an function module with table parameters as ACTOR_TAB (type SWHACTOR) and AC_CONTAINER (Type
            SWCONT). You can aswell copy the FM used in 168 rule and change it. check the logic mentioned below.
        b. In PFAC transaction, go to container tab and create 2 container elements.  For amount and Mail_indicator (type should be
            same as that of the amount field in your workflow) .
    2. Use this Rule in your workflow to send mail.
    Logic:
    ""Lokale Schnittstelle:
    *"       TABLES
    *"              ACTOR_TAB STRUCTURE  SWHACTOR
    *"              AC_CONTAINER STRUCTURE  SWCONT
    *"       EXCEPTIONS
    *"              NOBODY_FOUND
      INCLUDE <CNTAIN>.
      DATA BEGIN OF ORG_OBJECT OCCURS 0.
              INCLUDE STRUCTURE SWHACTOR.
      DATA END OF ORG_OBJECT.
      DATA: BEGIN OF NEW_AC_CONTAINER OCCURS 3.
              INCLUDE STRUCTURE SWCONT.
      DATA: END OF NEW_AC_CONTAINER.
      DATA: V_AMOUNT TYPE <AMOUNT FIELD>.
      DATA: V_MAIL_INDICATOR TYPE <FLAG>.
      REFRESH: actor_tab.
    Get the org-object under consideration. AMOUNT is the container name defined in your PFTC transaction
      SWC_GET_ELEMENT AC_CONTAINER 'AMOUNT' 'V_AMOUNT'.
    Get the org-object-type and the org-object id.
      SWC_GET_ELEMENT AC_CONTAINER 'MAIL_INDICATOR' V_MAIL_INDICATOR .
    Pass the org-object, the org-object-type and the org-object-id
    to a new container.
    The org object get a new name: ORG_AGENT.
      SWC_SET_ELEMENT NEW_AC_CONTAINER 'AMOUNT' 'V_AMOUNT'.
      SWC_SET_ELEMENT NEW_AC_CONTAINER 'MAIL_INDICATOR' V_MAIL_INDICATOR .
    check for V_AMOUNT and V_MAIL_INDICATOR.
    if the v_amount = 1000 .'
      if  v_mail_indicator = ' '.
        actor_tab-OTYPE = 'US'  .
        actor_tab-OBJID = 'SAPUSER1'.
        append actor_tab
      else.
        actor_tab-OTYPE = 'US'  . 
        actor_tab-OBJID = 'SAPUSER2'.
        append actor_tab
        actor_tab-OTYPE = 'US'  .
        actor_tab-OBJID = 'SAPUSER3'.
        append actor_tab
      endif.
    endif.
    Similarly write the logic for other conditions.
    This way you can use same for different purposes.
    If you pass the indicator that means you are sending mail to other approvers for information.
    Revert back if u need more help.
    Regards,
    Gautham

  • I need your expert opinion on how to create a map with multiple conditions.

    Hello.
    I need your expert opinion on how to create a map with multiple conditions.
    I have a procedure (which i cannot import or re-create in OWB due to the bug), so i am trying to create a map instead :-(
    How can i create a cursors within the map?
    My function creates table and cursor.
    Then it will have to check for duplicates in the tables (the one created and another table) - the criteria for finding duplicates is a number of fields.I then need to place few different conditions (if some attributes are not available) and it has to load cursor based on this conditions. The next step is to fetch the data into the cursor based on what attributes are missing.
    The next thing it will do is insert the data into table (if record doesn't exist), output the error in separate table is record is corrupted, or update the record with changed information.
    In short i need to re-create match / merge but with conditions, iterations etc 'built into' it.
    I can read up on available functions - it's just what would be the best options? and what would be the best approach to do so?
    In my function i use %rowtype - but cannot use it in owb - so what would be the alternative? i don't really want to create a lot of variables and then have a nightmare of maintaing it. are there any tips regarding this?
    having looked through Oracle dedupe - it's not really what i need because it is just DISTINCT.
    I would appreciate any help / advise on this.
    Thank you very much

    thanks a lot for your reply - i will look into this option :-)
    it is a bit more complicated now as i have to re-create the match / merge and then somehow 'tweak' it to achieve the result i need.
    At the moment i am looking to breakdown the package into smaller chunks 'functions' and try creating the map that way.
    Anyway, thank you very much for your suggestion.

  • How can we use DECODE function in where clause.

    Hi Guys,
    I have to use DECODE function in where clause.
    like below
    select * from tab1,tab2
    where a.tab1 = b.tab2
    and decode(code, 'a','approved')
    in this manner its not accepting?
    Can any one help me on this or any other aproach?
    Thanks
    -LKR

    >
    I am looking for to decode the actual db value something in different for my report.
    like if A then Accepted
    elseif R then Rejected
    elseif D then Denied
    these conditions I have to check in where clause.
    >
    what are you trying to do?
    may be you are looking for
    select * from tab1,tab2
    where a.tab1 = b.tab2
    and
       (decode(:code, 'A','Accepted') = <table_column>
        or
        decode(:code, 'R','Rejected') = <table_column>
       or
        decode(:code, 'D','Denied') = <table_column>
       )

  • Advance Aggregation based on multiple conditions

    Hi members,
    I have a situation where I need to aggregate data based on multiple conditions. Relevant details of the problem is as follows.
    There is a table (let's call X). It has following columns:
    Transaction_Time (date)
    Transaction_direction (Possible values IN or OUT)
    Column_1
    Column_2
    Based on the columns: Transaction_direction, Column_1, Column_2, the type of the transaction will be derived. For example, if transaction_direction='IN' then transaction type is IN, if 'OUT' then transaction types are Out. Similarly if Column_1=Column_2 then transaction type is Txn_3 otherwise 4.
    Based on date and transaction types the aggregation will happen.The sample output would be:
    Time, Transaction type (IN, OUT, Txn_3, Txn_4), Sum of transactions
    10-June-2013 00:00  IN Transactions  2500
    10-June-2013 00:00  Txn_3 Transactions 3590
    and so.
    IN and Out transactions are easy to be derived using decode() function. However avoiding multiple UNION ALL and write a single SQL for all four conditions is tricky one.
    Hope I clarified.
    Neeraj

    What version of Oracle are you using?
    If you're on 11.x you can use the UNPIVOT feature as follows:
    with t (Transaction_Time, Transaction_direction, Column_1, Column_2) as (
    select date '2013-06-10', 'IN', 1, 1 from dual union all
    select date '2013-06-10', 'IN', 2, 2 from dual union all
    select date '2013-06-10', 'IN', 1, 2 from dual union all
    select date '2013-06-10', 'IN', 3, 4 from dual union all
    select date '2013-06-10', 'OUT', 3, 3 from dual union all
    select date '2013-06-10', 'OUT', 3, 4 from dual
    select * from (
    select
      transaction_time
    , sum(case when transaction_direction = 'IN' then 1 end)  as IN_count
    , sum(case when transaction_direction = 'OUT' then 1 end) as OUT_count
    , sum(case when Column_1 = Column_2 then 1 end)           as Txn_3_count
    , sum(case when Column_1 != Column_2 then 1 end)          as Txn_4_count
    from t
    group by transaction_time
    unpivot (
      txn_count for transaction_type in (
         IN_count as 'IN'
      ,  OUT_count as 'OUT'
      ,  Txn_3_count as 'Txn_3'
      ,  Txn_4_count as 'Txn_4'
    order by transaction_time, transaction_type
    TRANSACTION_TIME TRANSACTION_TYPE TXN_COUNT
    2013-06-10       IN               4      
    2013-06-10       OUT              2     
    2013-06-10       Txn_3            3      
    2013-06-10       Txn_4            3      
    If you're okay with getting one row per date with the 4 counts you can just use the inner select above, i.e.
    select
      transaction_time
    , sum(case when transaction_direction = 'IN' then 1 end)  as IN_count
    , sum(case when transaction_direction = 'OUT' then 1 end) as OUT_count
    , sum(case when Column_1 = Column_2 then 1 end)           as Txn_3_count
    , sum(case when Column_1 != Column_2 then 1 end)          as Txn_4_count
    from t
    group by transaction_time
    order by transaction_time
    TRANSACTION_TIME IN_COUNT OUT_COUNT  TXN_3_COUNT  TXN_4_COUNT
    2013-06-10       4        2          3            3      
    If you want to sum transaction amounts then use the same logic, except in the case statements replace 1 with the column you want to sum.
    Regards,
    Bob

  • Multiple Conditions\Actions in a Workflow

    I am in the process of creating an expense approval form with a workflow that has two Approval stages. In the first stage, however, the approver would be dynamic based on a selection in the form. The second stage approval would go to the same
    person\group. What's the best\correct way to do multiple\conditions\actions in a single step? As an example of the workflow:
    If Field1 equals Value1 Assign a task to Person1. If Associated Task is Approved create a new Task and Assign it to Person 10
    there would be about 12 different iterations of the first step, Value2 Assign to Person 2 and so on.

    Hi pjs, it depends on who the person is/how they're related to the selection on the form. If it's the user's manager, you can get that information by using the link below. If there's no real correlation to the selection made, then you'd have to make a list
    with two columns- "selection" and "person to email." Then check that list against the selection and get the corresponding email for the particular approver.
    http://www.sharepointanalysthq.com/2011/04/user-profile-data-in-sharepoint-designer-workflows/
    cameron rautmann

  • Multiple condition does not work

    Hi,
    I took a copy of the standard Leave request workflow (WS12300111) to a new workflow (WS90000002).
    The class that was used in this workflow (CL_PT_REQ_WF_ATTRIBS) was also replaced with a copy (ZHR_CL_PT_REQ_WF_ATTRIBS).
    The workflow is used for the approval of leave requests.
    Now in the workflow there is a multiple condition which verifies whether the request was approved, rejected or withdrawn (this was also there in the standard).
    The condition contains the rules:
    Approved    &REQ.STATUS& = POSTED or &REQ.STATUS& = APPROVED or &REQ.STATUS& = ERROR
    Withdrawn  &REQ.STATUS& = WITHDRAWN
    Other values Rejected
    --> REQ is an object of the class mentioned above. The rules were created in the normal way by clicking on the object in the container.
    The workflow always stops at this condition, because it can not define the value of REQ.
    If I check the container in the workflow report, the field REQ and its STATUS are correctly filled.
    What could be wrong here?
    Thanks,
    Wim

    Hi,
    I solved it...
    Just had to add a commit work to the task that is executing the status change of the request.
    Kr,
    Wim

  • Error in conditional map using User Defined Function

    All,
    In my mapping I basically have a user defined function that returns the filename of my inbound file from the adapter-specific message attributes (file adapter).  I know this is coded properly because if I simply assign this function to my destination field I can see the filename in the payload XML.
    However if I conditionally check that returned value using if,then,else I get an error message stating:
    "During the application mapping com/sap/xi/tf/_MaterialData2ZcustProdMastMulti_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformation"
    Essentially in my if I'm checking if the value returned by my user defined function is equal to the constant "SOMECONSTANT" then I'm setting my destination field to some other constant value.  Otherwise it's equal to a different constant value.
    Any thoughts?

    Claus,
    Thanks for the help.  I actually had figured the problem out on my own.  Sorry for not updating the thread sooner.  What happened was this (as I suspected it wasn't related to my user defined function).  For the newbies out there (of which I'm one) the problem was I was comparing strings in the graphical mapping tool using the Boolean "EQUALS" rather than the Text "EQUALSS".
    Can you give yourself points for solving

  • If Statement Multiple Conditions

    Using LiveCycle, FormCalc or JavaScript.
    I am trying to create an if statement with multiple conditions.
    a Sum field calculates a series of numeric input fields. I want the result in the Sum field to determine the expression in a final field. 
    If the Sum is <30MM then "50000" also if the Sum is >30MM but <60MM then "125000" also if the Sum is >60MM but <100MM then "250000" also if the Sum is >100MM but <300MM then "375000" also if the Sum is >300MM then "500000"
    I have only been able to figure out a single if then for the first condition but not able to include the whole set of conditions and the multiple results.
    Help would be much Appreciated!
    Thank you in advance.

    Tried a few variations of this and still seem not
    to be able to find a solution to this issue. I'm surprised my google searches are bringing up better examples because there seems to be an example of everything else.
    Any more detailed advive?

  • Send multiple email attachments using FM SO_NEW_DOCUMENT_ATT_SEND_API1.How?

    Hi All,
    I have a requirement to send email to an external ID for which I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1.Can anyone give a sample code to send multiple excel attachments using this function module.
    Points would be rewarded.
    Thanks
    Archana.

    Check the Thread,,
    Re: more than 1 attachements/sheets in SO_DOCUMENT_SEND_API1

Maybe you are looking for

  • Conversion of Characteristic Values to SIDs

    Does anyone know why this DTP step would take 15 - 20 min for 10,000 records?

  • My itunes library is no longer syncing with my iphone

    My playlists within iTunes are no longer syncing with the playlists on my iPhone

  • Serial No in cross tab

    i need to give serial no in cross tab.... i had given in group header... i have 5 different groups.. so i need to refresh the serial no for each cross tab... Please help me... Thanks in Advance.......................

  • I need to uninstall or remove an add-on which has messed up my FarmTown game

    Two days ago I noticed a "ladder" beneath my farms on FarmTown. I play it often and it showed upwards of 100 friends/neighbors that either helped my farm, sent a gift to me or was requesting help, etc. I got sick of looking at that stuff at the botto

  • Site Definition not working

    I am trying to define my ftp info in CS5 and it is not working. The 4 options on the left side when you try to define a site (site, servers, version control, and advanced settings) are all not available to click on. Can someone please tell me what to