Gaps in data

Hi.  I am trying to save a lot of data at a high frequency:
36 Analog Channels, 400 samples @ 4kHz per channel, each iteration.
I am saving the data inside my loop and this seems to cause a 20ms gap after each pass through.  Is there a way to use the write to lvm vi outside the loop?

Yes.  Producer/consumer architecture.
Search the forums for those words and you'll find numerous messages on it.

Similar Messages

  • Time Sparsity and Gaps in Data ???

    Hi,
    I have a cube with 7 dimensions and having over 70 million rows. I have made all dimensions including time to be sparse. Now the problem is that there are gaps in my data for certain days after I maintain cube, which seems strange. Also, the aggregation at lower levels(days) is not correct whereas aggregations on higher levels (like year) are absolutely correct.
    On the other hand, if i dont make time dimension sparse then there are no gaps in data and everything looks fine. All aggregations are fine in this case in every level.
    Can any1 explain this behaviour please ?
    Regards.

    Hi Riccardo:
    At your suggestion, I used the Convert From Dynamice Data to 2D array before saving the array using Write to Spreadsheet File.  When I collected 2 seconds of data at 1,000 Hz, there are fewer than 200 lines of data in the spreadsheet file (no gaps in the data, see the txt file attached). For comparison, the file saved using Write to Measurement File has close to 1,000 lines (with gaps in the data, see the xlsx file attached).  Thanks for your time.
    John
    Attachments:
    A16D1_1000Hz_2s.txt ‏20 KB
    A16D1_1000Hz_2s.xlsx ‏133 KB
    Analog_16AI_1DI_Timed_Datalogging(WriteSpreadsheet).vi ‏116 KB

  • Gaps in data saved as LVM

    I am using 2 USB-6009s to collect 16 channels of analog data and the 2 devices are not synced.  The data files attached were collected at 1,000 Hz for 2 sec using the Write to Measurement File function.
    1. When the data were saved as a text (lvm) file [the csv file attached], there are gaps in the data.  However, there are no gaps when saved as an Excel file.
    2. When saved as Excel with 'absolute' timestamps, the time column starts with 00.000 and then reset to 00.000 at non-regular intervals (as in the spreadsheet attached).  The time column has continuous time when the 'absolute' option is deselected,
    If the gaps are related to the non-synchronization of the 2 devices, why are there no gaps when saved as Excel files?  Thanks for your time.
    Attachments:
    Analog_16Ch_Timed_Datalogging_Dell.vi ‏90 KB
    AI16_1000Hz_2s(absolute timestamp).xlsx ‏126 KB
    AI16_1000Hz_2s.csv ‏304 KB

    Hi Riccardo:
    At your suggestion, I used the Convert From Dynamice Data to 2D array before saving the array using Write to Spreadsheet File.  When I collected 2 seconds of data at 1,000 Hz, there are fewer than 200 lines of data in the spreadsheet file (no gaps in the data, see the txt file attached). For comparison, the file saved using Write to Measurement File has close to 1,000 lines (with gaps in the data, see the xlsx file attached).  Thanks for your time.
    John
    Attachments:
    A16D1_1000Hz_2s.txt ‏20 KB
    A16D1_1000Hz_2s.xlsx ‏133 KB
    Analog_16AI_1DI_Timed_Datalogging(WriteSpreadsheet).vi ‏116 KB

  • Fill gaps in Dates

    I have a table like this
    DDL for table:
    CREATE TABLE TEST1
      ID        VARCHAR2(20 BYTE),
      HH_START  DATE,
      HH_END    DATE
    Data for table:
    SET DEFINE OFF;
    Insert into TEST1
       (ID, HH_START, HH_END)
    Values
       ('144813', TO_DATE('01/26/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST1
       (ID, HH_START, HH_END)
    Values
       ('144813', TO_DATE('01/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('11/18/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST1
       (ID, HH_START, HH_END)
    Values
       ('144813', TO_DATE('01/10/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/11/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST1
       (ID, HH_START, HH_END)
    Values
       ('944813', TO_DATE('01/26/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST1
       (ID, HH_START, HH_END)
    Values
       ('944813', TO_DATE('01/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('11/18/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST1
       (ID, HH_START, HH_END)
    Values
       ('944813', TO_DATE('01/10/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/11/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;The table will contain multiple ID's. I just have 2 as sample. The reqiurement is we need to fill in the date gaps for each ID. For instance the final data for 144813 should look like:
    ID     HH_START     HH_END
    144813     1/26/2010     1/30/2010
    144813     1/30/2010     11/18/2010
    144813     11/18/2010     1/10/2011
    144813     1/10/2011     1/11/2011
    The gaps could be in many places. Thank you for your inputs.

    select  id,
             hh_start,
             hh_end
       from  test1
    union all
    select  id,
             hh_start,
             hh_end
       from  (
              select  id,
                      lag(hh_end) over(partition by id order by hh_start) hh_start,
                      hh_start hh_end
                from  test1
       where hh_start != hh_end
    order by id,
             hh_start
    ID                   HH_START  HH_END
    144813               26-JAN-10 30-JAN-10
    144813               30-JAN-10 18-NOV-10
    144813               18-NOV-10 10-JAN-11
    144813               10-JAN-11 11-JAN-11
    944813               26-JAN-10 30-JAN-10
    944813               30-JAN-10 18-NOV-10
    944813               18-NOV-10 10-JAN-11
    944813               10-JAN-11 11-JAN-11
    8 rows selected.
    SQL> SY.

  • Finding Gaps In Date Range

    I was recently asked to help create a query at my company to search for date gaps in employment status history. My table data looks similar to this
    employee_id employment_status beg_date end_date
    1               Active               1990-01-01          1991-01-01
    1               Leave               1991-02-01          1993-06-03
    1               Active               1993-06-04          1995-02-01
    1               Fired               2000-06-01          2299-12-31
    So the gap im looking for would be from 1995-02-01 and 2000-06-01
    Unfortunately as well, I dont have admin access to the database in order to be able to create an index, or do any fancy PL/SQL, im pretty much limited to the most basic SQL possible.
    Any help appreciated!

    If your database supports analytic functions, the following query should give what you want.
    with sample_data as (
      select 1 employee_id, 'Active' employment_status, date '1990-01-01' beg_date, date '1991-01-01' end_date from dual union all
      select 1, 'Leave', date '1991-02-01', date '1993-06-03' from dual union all
      select 1, 'Active', date '1993-06-04', date '1995-02-01' from dual union all
      select 1, 'Fired', date '2000-06-01', date '2299-12-31' from dual
    select employee_id,
           employment_status as last_status,
           end_date as gap_lower_bound,
           next_date as gap_upper_bound,
           next_status
    from
      select t.*,
             lead(beg_date) over(partition by employee_id order by beg_date) next_date,
             lead(employment_status) over(partition by employee_id order by beg_date) next_status
      from sample_data t
    where next_date > end_date + 1
    EMPLOYEE_ID LAST_STATUS GAP_LOWER_BOUND GAP_UPPER_BOUND NEXT_STATUS
              1 Active      01/01/1991      01/02/1991      Leave
              1 Active      01/02/1995      01/06/2000      Fired
    Note #1 : the WITH clause is just there to generate some test data "on-the-fly", you can remove it and use your real table in place of SAMPLE_DATA in the main query.
    Note #2 : unless you made a typo, the gap 01/01/1991 to 01/02/1991 should also be retrieved.
    BTW, for specific questions about SQL or PL/SQL please use the {forum:id=75} forum.
    Edited by: odie_63 on 27 févr. 2011 17:16

  • How to find gaps in data?

    Hi!
    I have the following problem.
    Data:
    range_id actual_nr
    AAA 001AAA
    AAA 002AAA
    AAA 003AAA
    AAA 006AAA
    AAA 007AAA
    AAA 009AAA
    BBB 001BBB
    BBB 002BBB
    etc.
    I have to get report in the following form
    from to nr_of_rows
    001AAA 003AAA 3
    006AAA 007AAA 2
    009AAA 1
    001BBB 002BBB 2
    etc.
    As you can see if there is a gap in sequence then I have to calculate how many rows were in sequence before the gap.
    Can somebody give me some hints or even working statement?

    How's this?
    WITH
         Sample_Data
    AS
          SELECT 'AAA' range_id, '001AAA' actual_nr FROM Dual UNION ALL
          SELECT 'AAA' range_id, '002AAA' actual_nr FROM Dual UNION ALL
          SELECT 'AAA' range_id, '003AAA' actual_nr FROM Dual UNION ALL
          SELECT 'AAA' range_id, '006AAA' actual_nr FROM Dual UNION ALL
          SELECT 'AAA' range_id, '007AAA' actual_nr FROM Dual UNION ALL
          SELECT 'AAA' range_id, '009AAA' actual_nr FROM Dual UNION ALL
          SELECT 'BBB' range_id, '001BBB' actual_nr FROM Dual UNION ALL
          SELECT 'BBB' range_id, '002BBB' actual_nr FROM Dual
    SELECT
         MIN(actual_nr_start)     actual_nr_start,
         actual_nr_finish,
         MAX(Total)
    FROM
          SELECT
              range_id,
              MIN(actual_nr)     actual_nr_start,
              MAX(actual_nr)     actual_nr_finish,
              MAX(Level)     Total
          FROM
              Sample_Data
          CONNECT BY
              range_id          = PRIOR range_id
             AND     substr(actual_nr, 1, 3)     = substr(PRIOR actual_nr, 1, 3) + 1
          GROUP BY
              range_id,
              CONNECT_BY_ROOT actual_nr
    GROUP BY
         actual_nr_finish
    ORDER BY
         SubStr(actual_nr_start, -3),
         actual_nr_start;Message was edited by:
    Brian Tkatch 2
    consolidated two levels.

  • SQL Lead & Lag to find gap between dates

    i have a table with two columns event_start and event_end :
    CREATE TABLE MYBATCHTAB
      EVENT_START  DATE                             NOT NULL,
      EVENT_END    DATE                             NOT NULL
    and my data is :
    Insert into MYBATCHTAB
       (EVENT_START, EVENT_END)
    Values
       (TO_DATE('08/12/2013 22:45:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2013 23:55:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into MYBATCHTAB
       (EVENT_START, EVENT_END)
    Values
       (TO_DATE('08/12/2013 15:30:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2013 17:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into MYBATCHTAB
       (EVENT_START, EVENT_END)
    Values
       (TO_DATE('08/12/2013 16:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2013 17:30:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into MYBATCHTAB
       (EVENT_START, EVENT_END)
    Values
       (TO_DATE('08/12/2013 20:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2013 22:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Event Start
    Event End
    08/12/2013 15:30:00
    08/12/2013 17:00:00
    08/12/2013 16:00:00
    08/12/2013 17:30:00
    08/12/2013 20:00:00'
    08/12/2013 22:00:00
    08/12/2013 22:45:00
    08/12/2013 23:55:00
    and i want to find the first whole start - end period in this example start : 15:30 - end 17:30 (merging  record 1&2 )
    but not the third one for example not 15.30 - 22:00 or not 15.30 23:55 because there are gaps between end dates.
    how can i do this using lead&lag ? 
    I'm not sure if this is the best approach

    Maybe a baby-step solution
    select event_start,event_end
      from (select event_start,
                   case when overlap is not null
                        then case when lead(overlap,1) over (order by event_start) is not null
                                  then lead(event_end,1) over (order by event_start)
                                  when lag(overlap,1) over (order by event_start) is not null
                                  then null
                             end
                        else event_end
                   end event_end
              from (select event_start,event_end,
                           case when lead(event_start,1) over (order by event_start) <= event_end
                                  or lag(event_end,1) over (order by event_start) >= event_start
                                then 'overlap'
                           end overlap
                      from mybatchtab
    where event_end is not null
    order by event_start
    EVENT_START
    EVENT_END
    08/12/2013 15:30:00
    08/12/2013 17:30:00
    08/12/2013 20:00:00
    08/12/2013 22:00:00
    08/12/2013 22:45:00
    08/12/2013 23:55:00
    or when there can be more than two consecutive overlaps
    select event_start,
           event_end
      from (select case when lag_overlap is null
                        then event_start
                   end event_start,
                   case when coalesce(lead_overlap,lag_overlap) is null
                        then event_end
                        when lag_overlap is null and lead_overlap is not null
                        then lead(event_end) over (order by event_start)
                    end event_end
              from (select event_start,event_end,
                           case when event_start < lag(event_end) over (order by event_start)
                                then 'overlap'
                           end lag_overlap,
                           case when event_end > lead(event_start) over (order by event_start)
                                then 'overlap'
                           end lead_overlap
                      from mybatchtab
             where lead_overlap is null
                or lag_overlap is null
    where event_end is not null
       and event_end is not null
    order by event_start
    Regards
    Etbin

  • [Bug?] Hypertrend Draws 'Fake' Gaps in Data

    Hi
    I have noticed Hypertrend drawing gaps in the data (when there is actually data there). This can be confirm when you zoom in on the data. Is this a known issue, or is there any workaround/configuration? The images are from Hypertrend in LabVIEW, but we have seen it in MAX too.
    Cheers
    -JG
    Certified LabVIEW Architect * LabVIEW Champion
    Solved!
    Go to Solution.

    Here are some prior discussions on the subject...
    http://forums.ni.com/t5/Real-Time-Measurement-and/Distributed-System-Manager-Historical-Trend/m-p/99...
    Also see attachment for a Jing video of the problem.  This occurs in DSM 2009 and 2010 and on multiple machines.
    Here is the final result after much rangling with NI:
    From: Mark Black [mailto:[email protected]]
    Sent: Thursday, January 21, 2010 4:53 PM
    To: Sachs, Michael A. (MSFC-ET30)[Intelligent Systems]
    Cc: Roger Hebert
    Subject: Re: DSM issues
    Hi Mike,
    We do have a CAR for this issue (#178809), but its a general CAR for these
    types of Hypertrend drawing issues that your case fits into. Currently
    this bug is not targeted to be fixed for SP1, but I have contacted our Shanghai
    development team for more an update.  Have you seen this issue on multiple
    different systems?  Have you seen this issue with plots not tied to your
    GPS synched cRIO?
    Thanks,
    Mark Black
    Product Support Engineer - LabVIEW R&D
    National Instruments
    [email protected]
    (512) 683-8929
    Attachments:
    2010-10-18_0907.zip ‏3018 KB

  • Find the latest Start date after a gap in date Field For each id

    Hi All, Can anyone help me in this, as it is so urgent ..My requirement is to get the latest start date after a gap in a month for each id and if there is no gap for that particular id minimum date for that id should be taken….Given below the scenario
    ID          StartDate
    1            2014-01-01
    1            2014-02-01
    1            2014-05-01-------After Gap Restarted
    1            2014-06-01
    1            2014-09-01---------After last gap restarted
    1            2014-10-01
    1            2014-11-01
    2            2014-01-01
    2           2014-02-01
    2            2014-03-01
    2            2014-04-01
    2            2014-05-01
    2            2014-06-01
    2            2014-07-01
    For Id 1 the start date after the latest gap is  2014-10-01 and for id=2 there is no gap so i need the minimum date  2014-01-01
    My Expected Output
    id             Startdate
    1             2014-10-01
    2             2014-01-01
    Expecting your help...Thanks in advance

    If you're using SQL Server 2012 this will work for you...
    IF OBJECT_ID('tempdb..#temp') IS NOT NULL
    DROP TABLE #temp
    GO
    CREATE TABLE #temp (
    ID INT,
    StartDate DATE
    INSERT #temp (ID, StartDate) VALUES
    (1,'2014-01-01'),
    (1,'2014-02-01'),
    (1,'2014-05-01'),
    (1,'2014-06-01'),
    (1,'2014-09-01'),
    (1,'2014-10-01'),
    (1,'2014-11-01'),
    (2,'2014-01-01'),
    (2,'2014-02-01'),
    (2,'2014-03-01'),
    (2,'2014-04-01'),
    (2,'2014-05-01'),
    (2,'2014-06-01'),
    (2,'2014-07-01')
    -- SQL 2012 and later --
    ;WITH gg AS (
    SELECT
    COALESCE(DATEDIFF(mm, LAG(t.StartDate, 1) OVER (PARTITION BY t.ID ORDER BY t.StartDate), t.StartDate), 2) AS GetGap
    FROM #temp t
    ), did AS (
    SELECT DISTINCT t.ID FROM #Temp t
    SELECT
    did.ID,
    x.StartDate
    FROM
    did
    CROSS APPLY (
    SELECT TOP 1
    gg.StartDate
    FROM gg
    WHERE did.ID = gg.ID
    AND gg.GetGap > 1
    ORDER BY gg.StartDate DESC
    ) x
    If you're on an earlier version than 2012, let me know. It's an easy rewrite but the final code isn't as efficient.
    Jason Long

  • Need to find out gap in data

    Hi All
    I have the following records:
    --Drop Table
    drop table agreement;
    drop table GRP_INFO;
    --Create table
    create table agreement
    Agreement_Id Number(5),
    Coverage_Effective_Date Date,
    COVERAGE_termination_date date
    Create Table GRP_INFO
    Agreement_Id Number(5),
    Grp_Id Number(5),
    Effective_Date Date,
    TERMINATION_DATE Date
    --Insertion
    Insert Into Agreement
    Select 100,'01JAN-2013','31-DEC-2013'
    From Dual;
    Insert Into Agreement
    Select 200,'01JAN-2013','31-DEC-2013'
    From Dual;
    Insert Into Agreement
    Select 300,'01JAN-2013','31-DEC-2013'
    From Dual;
    Insert Into Agreement
    Select 400,'01JAN-2013','31-DEC-2013'
    From Dual;
    Insert Into Grp_Info
    Select 100,1,'01-JAN-2013','31-MAR-2013'
    From Dual
    UNION ALL
    Select 100,2,'01-APR-2013','02-APR-2013'
    From Dual
    UNION ALL
    Select 100,3,'03-APR-2013','15-APR-2013'
    From Dual
    UNION ALL
    Select 100,4,'03-APR-2013','15-APR-2013'
    From Dual
    UNION ALL
    Select 100,5,'01-JUN-2013','31-DEC-2013'
    From Dual
    Union All
    Select 200,6,'01-JAN-2013','02-APR-2013'
    From Dual
    Union All
    Select 200,7,'03-APR-2013','15-APR-2013'
    From Dual
    Union All
    Select 200,8,'03-APR-2013','15-APR-2013'
    From Dual
    Union All
    Select 200,9,'01-JUN-2013','30-NOV-2013'
    From Dual
    Union All
    Select 300,10,'01-JAN-2013','15-APR-2013'
    From Dual
    Union All
    Select 300,11,'16-APR-2013','31-DEC-2013'
    From Dual
    Union All
    Select 400,12,'02-JAN-2013','31-DEC-2013'
    From Dual;
    COMMIT;
    --Query on agreement table
    Select * from Agreement;
    --Query Result
    agreement_id                    coverage_effective_date                     coverage_termination_date
    100                                         01-JAN-13                                                   31-DEC-13
    200                                         01-JAN-13                                                   31-DEC-13
    300                                         01-JAN-13                                                   31-DEC-13
    400                                         01-JAN-13                                                   31-DEC-13
    --Query on grp_info table
    agreement_id                  grp_id       effective_date          termination_date
    100                                              1                     01-JAN-13                       31-MAR-13
    100                                              2                     01-APR-13                       02-APR-13
    100                                              3                     03-APR-13                       15-APR-13
    100                                              4                     03-APR-13                       15-APR-13
    100                                              5                     01-JUN-13                        31-DEC-13
    200                                              6                     01-JAN-13                        02-APR-13
    200                                              7                     03-APR-13                        15-APR-13
    200                                              8                     03-APR-13                        15-APR-13
    200                                              9                     01-JUN-13                         30-NOV-13
    300                                              10                   01-JAN-13                         15-APR-13
    300                                              11                   16-APR-13                         31-DEC-13
    400                                              12                   02-JAN-13                          31-DEC-13
    --Result
    agreement_id
    100
    200
    400
    --Logic for the above result
    Each agreement_id have multiple grp_id and all grp_id or atleast one should cover all period agreement_id for example:
    - Agreement_id 100 has coverage effective date is 01-Jan-2013 and coverage_termination_date is 31-Dec-2013 and if you look into all record against agreement_id 100 then you can find that the period from 16-Apr-2013 till 31-May-2013 are missing so I need this agreement_id.
    - Agreement_id 200 has coverage effective date is 01-Jan-2013 and coverage_termination_date is 31-Dec-2013 and if you look into all record against agreement_id 200 then you can find that the period from 01-DEC-2013 till 31-DEC-2013 are missing so I need this agreement_id.
    - Agreement_id 300 has coverage effective date is 01-Jan-2013 and coverage_termination_date is 31-Dec-2013 and if you look into all record against agreement_id 300 then you can find that no period is missing so I don't need this agreement_id.
    - Agreement_id 400 has coverage effective date is 01-Jan-2013 and coverage_termination_date is 31-Dec-2013 and if you look into all record against agreement_id 300 then you can find that the period from 01-JAN-2013 till 01-JAN-2013 is missing so I need this agreement_id.
    Please let me know if you have any questions related to my scenario and I really appreciate if someone provide me solution for this issue.
    Regards
    Shumail

    Hi,
    Here's one way:
    WITH got_gap  AS
        SELECT agreement_id, effective_date, termination_date
        ,      CASE
                   WHEN  effective_date >
                         1 + MAX (termination_date) OVER ( PARTITION BY  agreement_id
                                                           ORDER BY      effective_date
                                                           ROWS BETWEEN  UNBOUNDED PRECEDING
                                                           AND           1         PRECEDING
                   THEN  1
               END  AS gap
        FROM    grp_info
    SELECT    g.agreement_id
    FROM      got_gap g
    JOIN      agreement a  ON  a.agreement_id = g.agreement_id
    GROUP BY  g.agreement_id
    HAVING    COUNT (g.gap)             > 0
    OR        MIN (g.effective_date)    > MIN (a.coverage_effective_date)
    OR        MAX (g.termination_date)  < MAX (a.coverage_termination_date)
    ORDER BY  g.agreement_id
    Output:
    AGREEMENT_ID
             100
             200
             400
    This makes no assumptions about effective_date and termination_date, except that effective_date <= termination_date on each row.  It's okay if different rows for the same agreement_id overlap, or if one encompasses another.
    Don't try to insert VARCHAR2 values (such as '01-JAN-2013') into DATE columns.  Use TO_DATE, or DATE literals.

  • Gaps between dates Query

    Hi,
    I needed to compute the gap time between employments for my database. The problem I am running into right now is I am computing unnecessary calculations. For example,
    Employment table:
    job start date end date
    A 13-01-2000 17-09-2002
    B 25-02-2003 23-07-2004
    C 22-01-2005 15-09-2007
    My query is as follows:
    SELECT A.job as Job1, B.job as Job2, (B.Start_Date - A.End_Date) as Gap_Time
    FROM Employment A, Employment B
    WHERE A.Start_Date != B.Start_Date AND A.End_Date != B.End_Date AND A.End_Date < B.Start_Date;
    The problem is, I should only be getting the gap times between jobs (A,B) and then (B,C), but my query also computes the gap time between A and C (there shouldn't be one though because C does not directly follow job A so that wouldn't be a gap time between jobs). I've tried to mess around with the different types of joins for the FROM part of the query but still haven't been able to figure this out. Thanks.

    Look at the Analytic Functions and specifically the key words LAG and LEAD.
    There is a lot of good advice at http://asktom.oracle.com and some demos in Morgan's Library at www.psoug.org.

  • Finding gaps between dates in table

    Is this following possible in sql...
    Lets say I have a "sales" table with these fields
    SalesMan, SaleDate, Amount.
    and this data
    John, 6/may/07,90
    John, 4/may/07,330
    John, 2/may/07,200
    John, 9/apr/07,300
    John, 5/apr/07,300
    Dave, 9/jul/07,90
    Dave, 8/jul/07,90
    Dave, 4/jul/07,330
    Dave, 2/jul/07,200
    Dave, 4/jun/07,300
    Dave, 2/jun/07,300
    I want to ask the database "show me the third sale made by each sales man after any 2 week gap in sales"
    Here's the same data again...
    John, 6/may/07,90 --- I want this one
    John, 4/may/07,330
    John, 2/may/07,200
    <2 week gap>
    John, 9/apr/07,300
    John, 5/apr/07,300
    Dave, 9/jul/07,90
    Dave, 8/jul/07,90 --- and this one
    Dave, 4/jul/07,330
    Dave, 2/jul/07,200
    <2 week gap>
    Dave, 4/jun/07,300
    Dave, 2/jun/07,300
    My actual problem is more complicated but this is it in its most basic form.
    Any help is much appreciated.

    That's easy enough using the LAG analytic funtion.
    with testdata as (select 'John' name, to_date('6/may/07') sdate, 90 amount from dual
      union all select 'John', to_date('4/may/07'), 330 from dual
      union all select 'John', to_date('2/may/07'), 200 from dual
      union all select 'John', to_date('9/apr/07'), 300 from dual
      union all select 'John', to_date('5/apr/07'), 300 from dual
      union all select 'Dave', to_date('9/jul/07'), 90  from dual
      union all select 'Dave', to_date('8/jul/07'), 90  from dual
      union all select 'Dave', to_date('4/jul/07'), 330 from dual
      union all select 'Dave', to_date('2/jul/07'), 200 from dual
      union all select 'Dave', to_date('4/jun/07'), 300 from dual
      union all select 'Dave', to_date('2/jun/07'), 300 from dual
    ), sales_gaps AS (
      select name, sdate, amount, 
             lag(sdate,2) over (partition by name order by sdate, amount) -
             lag(sdate,3) over (partition by name order by sdate, amount) delta
      from testdata
    SELECT NAME, SDATE, AMOUNT FROM SALES_GAPS WHERE DELTA >= 14
    NAME SDATE                     AMOUNT                
    Dave 08-JUL-2007 12:00:00      90                    
    John 06-MAY-2007 12:00:00      90                    
    2 rows selected

  • Scheduling a background Job with gaps in dates

    Hi Experts,
    I am having a requirement : A background job has to be scheduled for running a program every 15 minutes and for every month.But this job should not run from date 10th to 15th of every month.For example,In july month Job should start run from 01.07.2014 to 31.07.2014 excluding 10.07.2014 to 15.07.2014.
    Can we achieve this without a custom program and using SM36?
    Regards,
    Arun.

    Hello Arun,
    is it possible to define a factory calendar to you in the system, if you can define one then you can define the 10-15 the of every month as holiday.
    We can select the factory calendar above defined in the job. This can be found by clicking on the restrictions button in the start condition screen.
    in that start date restrictions, you can find 5 options in those you can pick the do not execute the periodic job on sunday and holidays.
    but this will effect the sundays which are falling in 1-10 th & 15-31st of each month, will that be OK ?
    if you do not want to try out the above all steps, then you can simply create 2 job running for each month
    1st one for 1-10th of every month.
    2nd one for 16th to end date.
    Let us know in case of any concerns on the same.
    thanks,
    Bhaskar

  • Incremental BACKUP to resolve large gap in Data Guard

    Hi, all,
    We run into a situation that standby database was shutdown for a long time and had a large gap between the primary and standby. I am interested in the idea to use incremental backup from primary db to resolve the gap. Does anyone know the procedure to do the work? Our environment is Oracle 10g RAC R2 on both primary and standby, ASM. Any suggestions are highly appreciated. Thanks in advance

    Check Using RMAN Incremental Backups to Roll Forward a Physical Standby Database.

  • How do I fill in the gaps with data?

    Hi,
    I have paragraphs of data with a header which holds the ID I need to have against each row of that data.
    I want the Patient ID to fill fields below that row (where the 'Obs' and sequential numbers are) until it gets to the next patient id, and then make it do the same again and again until the end.
    Can this be done in a single SQL UPDATE statement?
    Thanks Daniel
    This is the data, this is all one column:
    Patient ID=1000207 regimen=EFV+ZDV+ddI Randomization Date=26/03/2004
    Obs
    1
    2
    3
    4
    5
    6
    7
    Patient ID=1000751 regimen=EFV+d4T+3TC Randomization Date=25/02/2004
    Obs
    8
    9
    10
    11
    12
    13
    14
    Patient ID=1001379 regimen=LVP+d4T+3TC Randomization Date=17/03/2004
    Obs
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    etc. etc.

    Hi,
    welcome to the forum.
    Please read SQL and PL/SQL FAQ
    Kindly post sample data (CREATE TABLE and INSERT statements), explain the business requirement and post your expected output.
    Don't forget to mention also your Oracle version as result of
    SELECT * FROM v$version;When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for