Query in SQL to retrieve records after an activity in a model.

I have a table with data below:

1 01/12/2015 INSERT 01:20:20

1 01/12/2015 DELETE 01:20:30

1 01/12/2015 INSERT 01:20:20

2 12/02/2015 INSERT 01:20:20

02/12/2015 2 DELETE 01:20:30

2 12/02/2015 INSERT 01:20:40

3 01/12/2015 INSERT 01:20:20

3 01/12/2015 DELETE 01:20:30

3 01/12/2015 INSERT 01:20:20

Now, I will ask a SQL to extract records that follows the model of INSERTION, then REMOVE, then REINSERT similar to below:


RECORD INSERT_TIMESTAMP DELETE_TIMESTAMP INSERT_AGAIN_TIMESTAMP

1 01/12/2015 01:20:20 01/12/2015 01:20:30 01/12/2015 01:20:40

2 2015/12/02 01:20:20 12/02/2015 01:20:30 02/12/2015 01:20:40

Could someone help me?

B

create table exmp (t_dt date, oper varchar2(10));
insert into exmp values(sysdate,'INSERT');
insert into exmp values(sysdate,'DELETE');
insert into exmp values(sysdate,'INSERT');
insert into exmp values(sysdate,'INSERT');
insert into exmp values(sysdate,'DELETE');
insert into exmp values(sysdate,'INSERT');
commit;

select t1.*
  from (select ex.t_dt record_insert_timestamp
              ,lead(t_dt) over(order by t_dt) delete_timestamp
              ,lead(t_dt,2) over(order by t_dt) INSERT_AGAIN_TIMESTAMP
              ,ex.oper cop
              ,lead(oper) over(order by t_dt) nextop
              ,lead(oper,2) over(order by t_dt) next2op
          from exmp ex) t1
where cop = 'INSERT'
   and nextop = 'DELETE'
   and next2op = 'INSERT';
1 17.12.2015 09:50:08 17.12.2015 09:50:11 17.12.2015 09:50:15 INSERT DELETE INSERT
2 17.12.2015 09:50:19 17.12.2015 09:50:21 17.12.2015 09:50:25 INSERT DELETE INSERT

I did something that I understood. I hope that it would be useful.

Tags: Database

Similar Questions

  • SQL query to get the NULL records after the last matching flag

    I have a xx1 table with id and flag columns. So I want the data in this table, after the last flag matched. I want that data to id 7 in the rooms. Even if the id 2,3,5 are null flag 'Y' was at 6. ID so I need a query to get the data of the xx1 table after the last correspondence flag (from 7 to 9 id).

    SQL > create table xx1

    2 (identification number,

    3 flag varchar2 (10));

    Table created.

    SQL > insert into xx1 values (1, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (2, null);

    1 line of creation.

    SQL > insert into values xx1 (3, null);

    1 line of creation.

    SQL > insert into xx1 values (4, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (5, null);

    1 line of creation.

    SQL > insert into xx1 values (6, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (7, null);

    1 line of creation.

    SQL > insert into values xx1 (8, null);

    1 line of creation.

    SQL > insert into values xx1 (9, null);

    1 line of creation.

    SQL > select * from xx1.

    FLAG OF THE ID

    ---------- ----------

    1. IS

    2

    3

    4. IS

    5

    6. IS

    7

    8

    9

    9 selected lines.

    SQL >

    Hello

    user11164339 wrote:

    Hi Frank - when I run the query, I don't see the results data.

    I get

    FLAG OF THE ID

    ----- ----------

    7

    8

    9

    What you do differently?

  • Update in crippling conditions of the record after query

    Dear members
    I have a single block record and I want to disable conditionaly update of the files after that query has retrieved the data. Problem is that if I disable the update of the record after motion trigger then she checks the condition for the very first record recoveries and it the condition is true, then the update is disabled for all records pulled, even if future reviews do not meet the condition. I use Forms - 10 g. Can U give a better solution? thanx.

    Hello

    You can also use the trigger once - new - Record - Instance to assess the State

     If condition Then
       Set_Block_Property( '...', UPDATE_ALLOWED, PROPERTY_FALSE ) ;
     Else
       Set_Block_Property( '...', UPDATE_ALLOWED, PROPERTY_TRUE) ;
     End if ;
    

    François

  • I have some problem in my query to sql server. If I press f5 to run it opens to record dialogue area nd do not run (I don't get successful... orders etc). Please help me

    I have some problem in my query to sql server. If I press f5 to run it opens to record dialogue area nd do not run (I don't get successful... orders etc). Please help me

    Hello

    SQL Server is not supported in these forums. I suggest that you ask your question again in one of the forums dedicated to Microsoft for him here:

    http://social.technet.microsoft.com/Forums/en-us/category/sqlserver .

    Thank you.   :)

  • Texteelement read only after it retrieve records

    Hi I have situation where I lov which record recover and fill the folder to other fields I have what it takes to define this textitem to read after it retrieve records the user cannot go back and enter the value after recover data. so the situation is using pass code type textitem example 009 and tab after that the user cannot go back and type again the textitem should read only am in the form of oracle 11 g

    Hello

    If this element of text attached to the lov is a single block record, use the SET_ITEM_PROPERTY procedure with the UPDATE_ALLOWED = property_false property.

    If it is a multi-record block, use the SET_ITEM_INSTANCE_PROPERTY procedure with the UPDATE_ALLOWED = property_false property.

    So, the logic might be:

    IF: blk_name.textitem is not null THEN - assuming a valid value entered via lov (you can check this if you set the "Post to list" item text to true).

    SET_ITEM_xxxxxxx ('blk_name.textitem', UPDATE-ADMITTED, PROPERTY_FALSE);

    END IF;

    Greetings,

    SIM

  • move to the current record after query execution

    Hi all

    I have a form where I can list all the jobs of the db that can start or stop.

    For more details, form has columns jobs, the current situation of db, action (drop-down start/stop)

    The user will see list of works on the screen and it goes directly at a check-in and departure (submit) work using drop-down for this record.

    Once they start and stop work, run query goes off to show the current state of employment.

    Now goes to my requirement, after the query is run, I want to go to the (employment) record that the user has begun the work.

    Currently, the cursor goes to the first record.

    Is there any oracle 10g AS property where I can get the current record, put it in setting and go to this record after having run query?

    Is there another way?

    Kind regards
    Leonard

    Hello

    If you are sure that the record after motion will keep the same position, you can before, store the current record in a variable number with Get_Block_Property (CURRENT_RECORD) integrated, then after query, use Go_Record() with the variable number stored in the parameter.

    If you think that, after re - question registration number can change, you need to browse your recordings in a loop, then stop navidation while you find the corresponding key.

    François

  • Query to retrieve records that have more than one assignment_id

    Hello

    I'm writing a query to extract all records in the table per_all_assignments_f that has more than one different assignment_id for each person_id. Here's the query I wrote, it retrieves the records, even if a person_id assignment_id duplicate, but I need records that have more than one assignement_id without duplicate for each person_id

    Select assignment_id, person_id, assignment_id
    Of per_all_assignments_f
    Having count (assignment_id) > 1
    Person_id group, assignment_id

    Thank you.
    PK

    Maybe something like that?

    select *
    From   per_all_assignments_f f1
    where  exists (select 1
                   from   per_all_assignments_f f2
                   where  f2.person_id = f1.person_id
                   and    f2.assignment_id != f1.assignment_id
                  );
    

    Published by: SomeoneElse on May 7, 2010 14:23

    (you can add a SEPARATE from the outer query if you wish)

  • How to know the execution time of query in sql plus

    Hello

    I want to know the duration of execution of query in sql more accompanied by statistics

    I say time is set on;
    Set autotrace on;
    Select * view where usr_id = "abcd";


    If the result is 300 lines it scrolls up until all the rows are retrieved and finally gives me the run time in 40 seconds, or 1 minute... (it is after all records scrolls)

    but when I run it in Toad he gives 350 milli seconds...

    I want to see the execution time in sql how to proceed

    client and database server 11g is g 10

    concerning
    REDA

    In sqlplus you can do set autotrace traces to suppress the display of the selected lines.

    John

  • Is there a limitation of length of sql in a record group?

    Record group contains 4 by union funcion sql statement. When this sql statement longer than 4000 characters then the record group do not allow me to add an additional column to another.

    My question is, is there a limitation of length of sql that record the group support?

    Developer 10g suit.

    Thanks in advance.

    As you have discovered that there is a limit in the form designer, on what size the SQL statement may be in the property Query Group Record in your record group.  Unfortunately, the forms for the Query Group property help topic Record does not that there is a limit or the limit.

    If your request does not fit into the Group Record Query property, you can try to use the integrated Create_Group_From_Query() to fill in your group.  Another option would be to create views in your database, and then select the view in the Query property group Record.

    If you opt to try the method of Create_Group_From_Query(), just set your Group Record in the navigation of the object by using a SELECT statement (your column names) twice and then programmatically remove the Group and re-create it with the high - Create_Group_From_Query ().  See the help topic for the function integrated for a code example.

    Craig...

  • How to convert the hierarchical query of SQL Server (CTE) to Oracle?

    How to convert the hierarchical query of SQL Server (CTE) to Oracle?

    WITH cte (col1, col2) AS
    (
    SELECT col1, col2
    FROM dbo. [tb1]
    WHERE col1 = 12
    UNION ALL
    SELECT c.col1, c.col2
    FROM dbo. [tb1] AS c INNER JOIN cte AS p ON c.col2 = p.col1
    )
    DELETE one
    FROM dbo. [tb1] AS an INNER JOIN b cte
    ON a.col1 = b.col1

    Hello
    Something like this maybe:

    DELETE FROM dbo.tb1 a
     WHERE EXISTS (
      SELECT 1
        FROM dbo.tb1 b
      WHERE a.co11 = b.col1
          AND a.col2 = b.col2
       START WITH b.col1 = 12
      CONNECT BY b.col2 = PRIOR b.col1)
    

    Although you need to do here is to check that CONNECT it BY SELECT, returns records you wait first, then the DELETION should work too.

  • GarageBand 10.1.2 to stop recording after 2 hours

    Hi all

    We use Garageband to record longer sessions. Real, we have the problem, that Garageband continues to record exactly after 2 hours and 15 minutes.
    We tried 6 times and it was always the same. There is enough free space on the disk (SSD) and he quickly enough (MacBook Pro with i7/16 GB RAM).

    You can start immediately after he stopped without registration issue.

    We use multitrack recording with 3 pickups.

    No idea why Garageband to stop recording after the same time?

    Thanks for your comments or ideas to solve this problem.

    It depends on the number of measures. Recording will stop after 9998 measures. If the tempo is high, the length of the record is shorten the with a slower tempo.

    Take a look at this page of bullets & OS: http://www.bulletsandbones.com/GB/FAQPages/RecordLength.html

    Another limit is the limit of file size of 4 GB for AIFF files, but you would not have reached this limit with only two hours of recording.

  • Retrieve data after a certain line

    Hi guys,.

    Any advice or assistance would be appreciated

    Question: How do I retrieve data after a certain line of a string of delimited by commas that are read from a port series?

    More info: to have a map which includes data values and can be read in the computer via a serial port. Example of a string of acquired data as below:

    Data = 1 bit/s = sensor tool
    ; Label, time, voltage, pressure, temperature, current
    A, 01:33, 5.1, 18.1, 31.2, -.
    B, 01:34, 5.5, 19.2, 30.5, -.
    Data = 1 bit/s = sensor tool
    ; Label, time, voltage, pressure, temperature, current
    A, 01:35, 5.3, 18.3, 30.1, -.
    B, 01:36, 5.1, 19.0, 30.5, -.

    Data = 1 bit/s = sensor tool
    ; Label, time, voltage, pressure, temperature, current
    A, 01:37, 5.1, 18.1, 30.8, -.
    B, 01:38, 5.3, 19.2, 30.1, -.

    The value of these data is kept up-to-date line by line. I would like to start to extract data only on the 3rd block of incoming data. I would not that the first 2 blocks incoming data.

    More info: currently, my idea to do this is to analyse the '; '. data"and put it in a counter. If there are 2 '; data' scanner, then woud counter set to True in a case to start structure to extract the output data. Please see my attached picture.

    However, I'm not able to create also a counter using a table that I can't use a while loop and register shift. You have an idea? Thank you very much.

    Hi pokerprof,

    If you plan to get the data individually, have you tried the following:

    Put the output of the select.vi (where it is used as part of the counter) to a comparison so that when we tell: counter-online 3, begin to extract.

    Alternatively, you can use the below:

    The number of iterations that you plan to run? My concern would be the overflow of integer of the meter (http://en.wikipedia.org/wiki/Integer_overflow).

    You can try like vi, illustrated by johnsold (if you get all the data in a single iteration).

    Thank you

    Warm greetings,

    Lennard.C

  • Error message when I run delete the query in SQL Server 2008.

    Error message when I run delete the query in SQL Server 2008 SP3.

    Error message:

    MSG 0, level 11, State 0, line 0
    A serious error occurred on the current command.  The results, if any, should be discarded.

    I never got any problem since 5 years.

    Please let me know what is the cause of the problem.

    You can get a response better/faster if repost you your question in the instances of SQL Server dedicated from Microsoft here:

    http://social.technet.microsoft.com/Forums/en-us/category/sqlserver .

    Thank you.   :)

    (I'm sorry, but I can't move this thread for you because the two forums are working on separate platforms)

  • PowerShot SX510 HS automatically stops video recording after 10-15 minutes in the record.

    PowerShot SX510 HS automatically stops video recording after 10-15 minutes on continuous recording. Is there a way to disable this option? I would like to record videos up until I press the button stop recording or the battery is low. I've disabled all the setting of energy saving, at least, I think I have.

    The camera has some limitations for registration, as do all models of Canon. Here's how you can extend your durations for registration to a maximum of about 1 hour, but there is a limit of 4BG regardless so once he hits 4 GB recording stops and has to be restarted.

    Also, the memory card has to be at least a class 6 rating or recording will stop as soon as possible regardless of the size of the clamp.

    It comes to page 161 of your manual

  • Picture disappears from the record after a reboot.

    Original title: WHAT CAUSES PICTURES TO MIGRATE

    Windows 7 Pro: make sure that the image is in the right file. Come back next day & I do a search because it is no longer in the original file. I'm the only person who uses this computer. I heard the complaint from others, but no solution.

    Hi Gardner,

    Thanks for posting your question in the Microsoft Community forums.

    I see from the description of the problem, as this image disappears from the record after a reboot.

    I imagine the inconvenience that you are experiencing. We are here to help and guide you in the right direction.

    To provide the proper resolution, that I would need more information on your side.

    Did you the latest changes on the computer before this problem?

    I suggest you to run the fixit and check if it helps.

    Diagnose and repair Windows files and folders problems automatically
    http://support.Microsoft.com/mats/windows_file_and_folder_diag/

    Let us know the status of the issue after you perform the troubleshooting steps. If you need help or information about the issue with the photo, I'll be happy to help you. We, at tender Microsoft to excellence.

Maybe you are looking for

  • How can I remove deal top ads? certain words are highlighted and clicking on redirects to another website.

    Some malware has invaded my browsers. Certain words are highlighted when I open a page with enable Java. These words highlight redirect me websites ad. I can avoid by turning off java, but so many Web sites will not work. Any help to remove this?

  • How to create a single VI accepting several input type definitions?

    Dear users, How to simplify (or change) the following code for better overview and maintenance: The structure on the top is a code handle my cluster (uninteresting code is blocked). On the bottom, there are clusters of several type defs, which I use.

  • Change the song in Windows Media Player

    How can I change the duration of a song?  The song is more than 4 minutes long and I need, may not be more than 2 minutes, 30 seconds.  I want to change the song while keeping the words.Is it possible that I can do this?

  • SSD in M17x-R4

    Hi guys,. I need help or advice please. I would like to replace my HDD with a SSD.  Is not a computer geek, I am at a loss of what to buy.  When I went to get a quote he asked me if it was "a SATA, PCIe etc. M2". I had to look stupid because he told

  • How to add or subtract 2 times, calculation with the calculator of windows 7?

    For example: I want to add 2 different times as follows. More time is with the format hours: Minutes: seconds. H MM SS 01:50:31 + 2:20:30 ------------------- 04:11:01 How to perform this calculation of time with Windows 7 or any other Calculator calc