Select data based on status priority

ID     PRO_ID     PRO_OBJ_ID     TASK_ID     DEVELOPER_ID     STATUS
121243     4940     37506     5250     6532     REJECTED
122063     4940     37506     5250     6532     CLOSE
138306     4940     37506     5250     6532     ACCEPTED
138307     4940     37506     5250     6532     WIP
Hi,
From the above table i need to select data based on status any status that is prior to CLOSE or ACCEPTED it must display all the status any status that is after CLOSE or ACCEPTED we must not consider.
In the above scenioro it must display only the first three status. after ACCEPTED it must not display any thing
Please suggest me a query how to write.
Thanks
Sudhir.

Try:
SQL> with t as (
  2  select 121243 id, 4940 pro_id, 37506 pro_obj_id, 5250 task_id, 6532 developer_id, 'REJECTED' status from dual union all
  3  select 122063, 4940, 37506, 5250, 6532, 'CLOSE' from dual union all
  4  select 138306, 4940, 37506, 5250, 6532, 'ACCEPTED' from dual union all
  5  select 138307, 4940, 37506, 5250, 6532, 'WIP' from dual union all
  6  select 138308, 4940, 37506, 5250, 6532, 'ACCEPTED' from dual union all
  7  select 138309, 4940, 37506, 5250, 6532, 'REJECTED' from dual union all
  8  select 121243, 4940, 37777, 5250, 6532, 'REJECTED' from dual union all
  9  select 122063, 4940, 37777, 5250, 6532, 'CLOSE' from dual union all
10  select 138306, 4940, 37777, 5250, 6532, 'ACCEPTED' from dual union all
11  select 138307, 4940, 37777, 5250, 6532, 'WIP' from dual union all
12  select 138308, 4940, 37777, 5250, 6532, 'ACCEPTED' from dual union all
13  select 138309, 4940, 37777, 5250, 6532, 'WIP' from dual
14  ) -- actual query starts here:
15  select t1.id
16  ,      t1.pro_id
17  ,      t1.pro_obj_id
18  ,      t1.task_id
19  ,      t1.developer_id
20  ,      t1.status
21  from   t t1
22  where id <= (select max(id)
23               from   t t2
24               where  t2.status in ( 'ACCEPTED', 'CLOSED' )
25               and    t1.pro_id = t2.pro_id
26               and    t1.pro_obj_id = t2.pro_obj_id
27               and    t1.task_id = t2.task_id
28               and    t1.developer_id = developer_id
29               );
        ID     PRO_ID PRO_OBJ_ID    TASK_ID DEVELOPER_ID STATUS
    121243       4940      37506       5250         6532 REJECTED
    122063       4940      37506       5250         6532 CLOSE
    138306       4940      37506       5250         6532 ACCEPTED
    138307       4940      37506       5250         6532 WIP
    138308       4940      37506       5250         6532 ACCEPTED
    121243       4940      37777       5250         6532 REJECTED
    122063       4940      37777       5250         6532 CLOSE
    138306       4940      37777       5250         6532 ACCEPTED
    138307       4940      37777       5250         6532 WIP
    138308       4940      37777       5250         6532 ACCEPTED
10 rows selected.If that doesn't work then please provide us some representative sample data again.

Similar Messages

  • Advaned warning for due date based on statuses

    Hi,
    While searching transactions, for the due date some icons are coming like(green squere, yellow triangle, tick mark, grayed dimond) and so on.
    can I maintain these icons based on statuses. Presently tick mark is coming for one of the statuses maintained in the status management. But for this we didn't maintained any configuration settings at IMG --> CRM --> Interaction center Web client --> Agent Inbox --> Map item attributes to inbox Attributes --> Define advanced warning for due date.
    Required quick response as it is business critical requirement.
    Thanks,
    Chandu

    Hello Praeva ,
    The event 1330 has a sample FM FKK_SAMPLE_1330. It doesnt even have a Standard Function Module.
    You need to create a Installation-Specific FM and put your code to determine the Due Date based on the logic.
    Rgds
    Ram Kumar.

  • Select Data based on User Permissions

    Post Author: nomore
    CA Forum: General
    I've got a Crystal Infoview server which is becoming quite cluttered with reports.In a lot of instances, I will have 4 or 5 copies of the same report which are tailored to specifc users. For example a sales report which will show data based on a specific customer. I could create on report with a parameter where the user could just select the customer - but i dont want some people to be able to see specific customers. So at present i have a seperate report for each customer - and then set the report permissions to only allow specific users to run it.I attended a course a while back where they showed us how, hiding particular fields/data to certain users if they should
    not be allowed to view it - but for the life in me i cannot remember at
    all how they did it.  Any tips greatly appreciated.

    Post Author: V361
    CA Forum: General
    In the special fields section is CurrentCEUserName, not sure if this would work for you, because I have CR XI
    You could surpress based on the id logged in, but that would be a lot of work, 
    Perhaps you could create a "permissions" list in excel or in the database if possible, with a list of the reports that each ID can run, then based on the id, you populate the list....
    CurrentCEUserName inserts (in a formula) the name that was used to log on to the current session when using the Log On to BusinessObjects Enterprise dialog box.

  • SELECT data based on partitions

    I know we have PARTITION clause in SELECT statement.
    My requirement is i need to select data from Last two partitions in which data is available.
    If we know the name of the 2 partitions then we can select and UNION ALL.
    But In my case, i dont know the partitition names too,
    I need to find out the names of the partitions using any subquery and i need to select from that.
    May i know how can i achieve this?
    Thanks

    Maybe you could adjust the below (NOT TESTED !) if the meaning of the recent 2 partitions is somehow connected with partition_position within [url http://download.oracle.com/docs/cd/E11882_01/server.112/e25513/statviews_2108.htm#REFRN20281]all_tab_partitions as I don't have a database at hand to find out how partitions are being numbered.
    declare
      the_sql   varchar2(32000) := q'{ your sql here }'; -- assumed having a where clause
      the_table varchar2(30)    := 'your_table_name';
    begin
      for i in (select partition_name
                  from all_tab_partitions
                 where table_name = the_table
                   and partition_position <= 2  -- assumed ascending order for partition numbering
      for i in (select partition_name
                  from (select partition_name,row_number() over (order by partition_position desc) rn
                          from all_tab_partitions
                         where table_name = the_table
                 where rn <= 2  -- assumed descending order for partition numbering
      loop
        substr(the_sql,1,instr(the_sql,'where')) || ' partition (' || i.partition_name || ') ' ||
        substr(the_sql,instr(the_sql,'where')) || ' union all ';
      end loop;
      the_sql := 'select * from (' || substr(the_sql,1,instr(the_sql,' union all ',-1,1)) || ')';
      dbms_output(the_sql);
    end;Regards
    Etbin

  • Facing problem in selecting data based on the join s tatement ppls suggest

    hi
    cosider a sceneio as below
    there  are six tables    table1
                                    table2 
                                    table3       table4 
                                                               table5 table6
    join conditons between tables
    table1-lclic (primary key) = table2-lclic
    table1-lgreg = table3-lgreg (PK for table 3)
    table2-pobj = table4-pobj
    i have used join statment to join table 1 table 2table3
    i want to select data from table5
    table5-ccngn and table6-text
    now condion for validation is that
    table5-field1 is selected if table4-ctsex = table3-ctsty and tehre is no link between table 5 and table 3 o nly link is through table 4
    table4-ctsnum=table5-ctsnum (primary keys)
    can anyone suggest how to format the select statement
    regards
    Arora

    Hi Nishant,
    Using Table Joins for multiple tables would severely hamper the performance of the SAP system.
    Instead use individual select statements for each database table, and later reconcile all the internal tables.
    <b>Reward points, if helpful.</b>
    Regards,
    Atin

  • Select data based insert

    Hi,
    Is there a way to select data to select data wht is been inserted in time. means there are so many insert process keep happing In my application i need to select which is happend very recently.
    How to select such data please suggest
    If table name is "Contribution" .
    Please suggest
    Thanks
    Sudhir

    Hi ,
    You can include a column as inserted_time and keep the data type as date and default value is sysdate, now every time a record is being inserted the inserted_time field will get populated with value sysdate,
    now to query the latest record you can use like below
    select <column-names> from <table-name>
    order by inserted_time descin this way you can view which all record are inserted recently. I hope it is clear :)
    If you have any doubt then tell.
    regards

  • How to select data, based on a specified or preset date/time range

    Hi,
    I am trying to construct a requirement like this in java/jsp.
    I have a table consisting of registered users info. Have a expiration date for every user, which was captured or set when they originally registered.
    I have to select all those users who are expiring two weeks from now.
    For example. if the current date is 14th, I should get a list of users who expire between the midnight of 24th sunday to 30th saturday. this covers the whole last 7days in that range. And so on.
    So based on the current date, the last midnight sunday to midnight saturday of that two week's range should be selected.
    The input fields for this range on the userend should default to this range.
    And also the user should be able to specify their own range and be able to pull data.
    the result should be populated as viewable as well as a downloadable tab de-limited file for mass mailing.
    (ex. the table might be queried for user info like id, email, expiration date, fullname, and shown accordingly in the jsp)
    I know this is a longshot.. but if somebody can guide me will be good as I am new to this forum and as well as java.

    Well, I can start you off with this:
    Calendar now = Calendar.getInstance();
    // shift 2 weeks and back to Sunday
    Calendar start = Calendar.getInstance();
    start.add(Calendar.DATE, 14);
    end.set(Calendar.HOUR, 0);
    end.set(Calendar.MINUTE, 0);
    end.set(Calendar.SECOND, 0);
    end.set(Calendar.MILLISECOND, 0);
    while(start.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
    start.add(Calendar.DATE, -1);
    // shift 2 weeks and up to Saturday (following Sundat midnight, actually)
    Calendar end = Calendar.getInstance();
    end.add(Calendar.DATE, 14);
    end.set(Calendar.HOUR, 0);
    end.set(Calendar.MINUTE, 0);
    end.set(Calendar.SECOND, 0);
    end.set(Calendar.MILLISECOND, 0);
    while(end.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
    end.add(Calendar.DATE, -1);
    At this point, start is the first Sunday before the day 2 weeks from today and end is the first Sunday after the day 2 weeks from today, both at midnight. You could make end stop at Saturday and make the time 23:59:59:999, of course.
    If you ran it today, it should be 11/9 and 11/16.

  • Need multiple variables to select data based on OR condition not AND condit

    Hello All,
    We have a requirement where we want the user to enter a variable 1X.  Then based on this entry select from the InfoCube to check multiple fields where this value could potentially be.  If we put variables on each characteristic in the query and let them input the same value for each, the system tries to find a record where all characteristics have this value.  Our situation is that we don't know if field1, field2, field3 will have this value.  So an OR condition, not an AND needs to be generated.
    We are stuck.  Has anyone tried this before?
    Thanks!

    You can create 3 restricted Key Figures.
    RKF1 : KF restricted by var1 on Char A
    RKF2 : KF restricted by var2 on Char B
    RKF3 : KF restricted by var3 on Char C
    Make var1, var2 and var3 as ready for input. Don't use variables in Free Characteristic

  • How to select data based on date range

    Hi all,
    how do I make the following scenario happen:
    I am tracking my sales people's performance from 1/01/00 to 1/01/09, and I want to give $200 bonuses to only those whom made a sale between 1/01/06 to 1/01/08.  I need a formula that captures the sale between 1/01/06 to 1/01/08 and assign a $200 bonus that I can then insert into my report as a field. 
    I've been trying with the "If" "then" functions, and I'm unsure how to incorporate the date field into it. 
    please help!
    Thanks,
    Frank

    Hi Newbie,
    You will have to create the following formula, call it @Bonus and place it in the detail section:
    If {date.field} >= Date(2006,01,01) and
    {date.field} <= Date(2008,01,01) then
    200 else 0
    You can then summarize it however you want.
    I hope this helps,
    Regards,
    Zack H.

  • Display of data based on priority

    Hi All,
    I have a requirement of displaying data based on the priority of numbers.
    Example: There are 3 Part Numbers- 342, 310, 317.
    I want to store this data in Lookup table(Multi).
    Is it possible to display the data based on the number like 310, 317 & then 342.
    Is there any other option to do this?
    Regards,
    Pramod

    Is it priority or is it sorting of records?
    If this is sorting then you can do it in data manager, in your lookup flat just click on field name (column name) data manager automatically sort the record or right click on column name>sort>ascending/descending.
    If this is priority case then please elaborate more.
    Howevere, In multivalued field when you will take say 310 and 317 in main table record and do search on it in both the cases 310 and 317, DM will display same field means this record will be common in 310 and 317.
    if your question is concerned to different tings, please explain.
    BR,
    Alok

  • Notification: Set priority and dates, based on the reference object

    Hello,
    I'm searching for an idea/solution, to set the priority of a notification automatically, depending on the entered reference object (F/L or equi).
    I.e. I want to classify the F/Ls and equis with a priority (e.g. via the classification, or F/L / equi master data). When the user creates a notification, and enters a F/L or equi, the priority should be selected from the object and set automatically.
    Thanks for your answers!
    Best regards
    Stephan

    Hello Pete,
    thank you for your answer. Unfortunatelly both user-exits seem not to work for my problem.
    QQMA0025: Default values when adding a notification
    Priority and dates can be modified, but in this step you don't have the functional location. I thought, I can send a popup in this user-exit, to ask for the functional location, but the functional location is deleted in a later step (before the 1st display of the notification header), i.e. the user has to enter it again.
    QQMA0018: Deadline setting based on entered priority
    Here you can only modify the dates / times, but not the priority.
    Another show stopper is, that the exits will only be processed once, i.e. in both cases, a change of the functional location doesn't adjust the dates/times.
    It seems, that exit "Before saving the notification" (as far as I remember QQMA0014) could be a solution.
    I see 2 problems ->
    1. the user enters the F/L or equi and nothing happens to the priority / dates -> sending a popup in the saving process to inform the user about the changes, could be a solution.
    2. What to do, when the user has already maintained priority and/or dates/times?
    I will have a look, if there are enhancement spots in the notification program. Perhaps this can help me (or better - my boss ).
    Best regards
    Stephan

  • Basic start date & Basic finish date based on Priority

    Dear Experts,
    When I am creating Notification & selecting Priority, System gives pop-up “do you want to specify new dates?” If I select yes system automatically change required start & required end based on Priority.
    Now my question is do we have same functionality for Maintenance order as priority field is available there (If we are directly creating a MO)?
    Even if we are creating WO from notification, required start & end dates copies to Basic start & Basic finish but if we change priority then no change in basic start & finish dates. Why?

    Greetings Parag,
    You may select the Priority in the initial screen of IW31 and the dates will shift accordingly, if you maintained the Relative Start &/or Relative End in
    SPRO > Plant Maintenance > Maintenance Processing > Maintenance & Service Orders > General Data > Define Priorities > Define Priorities for Each Priority Type
    If you want to change date based on Priority on the Order header screen, it's not possible in the standard to my knowledge, but you may easily develop an enhancement utilizing the user exit
    IWO10012 Maintenance order: Priority handling on central header
    or
    IWO10009 PM Order: Customer Check for 'Save' Event

  • Escalation process in Service Ticket based on the Priority,DueDate & Status

    Hi Experts,
    What is the standard way of Escalation process in SAP CRM Service Ticket management based on the Priority, Due Date and Status together. SLA can be usde with Service Ticket ?
    Based on the status, priority and due date/Time, how can I re-assign the ticket and send mail to the specific responsible employee or department to work on the ticket.
    Thanks
    Shaik Chand

    Hi Chand,
    pls check this below link ..
    http://help.sap.com/saphelp_sm40/helpdata/en/ec/7c83dc4ded11d5992600508b6b8b11/content.htm
    Regards,
    Raghu

  • JDBC to IDOC Scenario - select data in jdbc based on multiple conditions

    Hello
         I have a JDBC to IDOC Scenario. I have to select the records in JDBC based on different conditions each time. For example I have to select based on company code '1000' and Employee claasification 'E1' and date range. After I post these records in SAP again I want to select other records for some other company code '2000' and different business area and different dates. Basically I want to extract data multiple times based on different conditions.
    Hiow do I achieve this?
    Another question is in the JDBC to IDOC scenario since the sender adapter is JDBC and the sender adapter polls depending on the duration of time ( say 60 secs ) in the adapter once after I extract the data based on a condition how do I control in such a way that the same data is not extracted again.
    Thanks
    Naga

    Hi Naga,
    I have to select the records in JDBC based on different conditions each time. For example I have to select based on company code '1000' and Employee claasification 'E1' and date range. After I post these records in SAP again I want to select other records for some other company code '2000' and different business area and different dates. Basically I want to extract data multiple times based on different conditions.
    -->
    Such requirements cant be handle through select query of the sender...but you can handle this in the message mapping area.....you can fire a select query in the database to pick up records in a batch of 10K (do not keep any condition on this except for sorting). After the records come into PI you can send the message to your target based on the unique combination of "Company code+ Employee clasification + date range" handling this in the message mapping.
    Another question is in the JDBC to IDOC scenario since the sender adapter is JDBC and the sender adapter polls depending on the duration of time ( say 60 secs ) in the adapter once after I extract the data based on a condition how do I control in such a way that the same data is not extracted again.
    You can use the N--> C logic
    The data records that you pick have a corresponding control table i assume. There should be a field STATUS where the initial status of record should be N.
    After you pick the records this status should be made C so that only those records present in the database with status = N are picked up.
    Mention the condition Status = N in the select query.
    Thanks
    Dhwani

  • Creating report based on user selected Date Range

    Hello.
    I am trying to display an Apex report that selects data for the report based on a user entered date range.
    It's a simple page with two date picker fields (p18_start and p18_end).
    The report region SQL looks like this:
    SELECT *
    FROM prj_items
    WHERE LM_DT BETWEEN :p18_start AND :P18_end
    One table, one field on the table to search and two Apex variables.
    I thought this would be fairly simple, but I am obviously missing something.
    I not even sure what other information is needed to help me figure this out.
    -Jody

    Hi,
    You can set defaults for the datepickers if you need to - this could be done in a computation on the page for each item and conditional on the item being null.
    When I've done something similar to this, I've created two hidden page items - eg, :P19_FIRST_DATE and :P19_LAST_DATE and populated these with the earliest/latest date that the user could reasonably select (perhaps, in your case, the MIN(LM_DT) and MAX(LM_DT) values).
    Then your SQL would be:
    select * from PRJ_ITEMS
    where LM_DT BETWEEN TO_DATE(NVL(:P19_START,:P19_FIRST_DATE), 'DD-MON-YY')
    AND TO_DATE(NVL(:P19_END,:P19_LAST_DATE), 'DD-MON-YY')If you don't want to set default dates, you could do something like:
    SELECT * FROM PRJ_ITEMS
    WHERE (:P19_START IS NULL AND :P19_END IS NULL)
    OR (:P19_START IS NOT NULL AND :P19_END IS NULL AND LM_DT >= TO_DATE(:P19_START,'DD-MON-YY'))
    OR (:P19_START IS NULL AND :P19_END IS NOT NULL AND LM_DT <= TO_DATE(:P19_END,'DD-MON-YY'))
    OR (LM_DT BETWEEN TO_DATE(:P19_START,'DD-MON-YY') AND TO_DATE(:P19_END,'DD-MON-YY'))There are various reasons why your two dates are being cleared when the page is reloaded. Firstly, you should check the branch that returns to the same page - make sure you are not clearing the cache for the page. Then, have a look to see if there is a "reset page" process (usually created for you when you create a form page). Then, check the Source settings for the items. Typically, these would be "Only when current value in session state is null" and a Source Type of "Static Assignment" with the "Source Value or Expression" left empty.
    Andy

Maybe you are looking for

  • Help to create a Report Script

    Hi everyone, I'm trying to translate this calculation script line @REMOVE( @CHILDREN("P&L"), @LIST(@UDA ("Accounts", "wo_CC"), @UDA ("Accounts", "wo_C2"), "AX70000", "C71110") ) by this Report script line : <LINK (<CHILD ("P&L") AND NOT (<UDA ("Accou

  • N958GB - video pauses during recording

    Hello, I just got my new N958GB last week. I played with the camera and recorded video with no problems. I then went ahead and installed applications, such as yahoo go, youtube, and setup my e-mail. After this was completed, I went ahead and recorded

  • Reg: cannot access fields from field catalog in kea6 transaction

    hi experts, I am suppose to create a co-pa report . i dont find the required fields in the f4 help for the elements to be inserted in the report. i am able to see the fields in the transaction kea6 but cannot access them ... kindly help out points wi

  • Which authorizations are required for assigning a query to a role?

    Hi everybody, we try to set up some roles for "reporting power users". These guys should be alble to define new queries using BEx (works fine) and also should be able to assign these new defined queries to a role, so other users can use these roles.

  • Flash builder burrito to FB 4.5 issue

    Have seen all the threads on updating flash builder burrito to fb 4.5 and understand that fb burrito needs to be uninstalled.  I have a mobile application almost complete and do not want to lose this work.  How can I save those files and other necess