Extend a range of dates

I have the following query, which works without problem. This will expand the range of dates, proof of identity, in a list of dates for me:
SELECT     j_id
          ,  date_1
           + LEVEL
           - 1
             datum
FROM       (SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2
            FROM   DUAL)
CONNECT BY LEVEL <= (  date_2
                     - date_1
                     + 1);
How can I do this for more than 1 sheet well? for example
SELECT     j_id
          ,  date_1
           + LEVEL
           - 1
             datum
FROM       (SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2
            FROM   DUAL
            UNION
            SELECT 456 j_id, TO_DATE('01/02/2012', 'DD/MM/YYYY') date_1, TO_DATE('29/02/2012', 'DD/MM/YYYY') date_2
            FROM   DUAL)
CONNECT BY LEVEL <= (  date_2
                     - date_1
                     + 1);
Thank you.

Hello

Here's one way:

WITH   cntr          AS
(
     SELECT     LEVEL - 1     AS n
     FROM     (
              SELECT  MAX (date_2 - date_1)     AS max_dif
              FROM    table_x
          )
     CONNECT BY     LEVEL <= 1 + max_dif
)
SELECT       x.j_id
,       x.date_1 + c.n
FROM       table_x  x
JOIN       cntr        c  ON  c.n <= x.date_2 - x.date_1
ORDER BY  x.j_id
,            c.n
;

If you do any filtering, it may be more effective to do this first. Start the WITH clause with a subquery that performs filtering, then use this result placed instead of your full table in the view online within the cntr as well as in the main query.
For example:

CREATE TABLE  table_x         AS
         SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2
            FROM   DUAL
            UNION
            SELECT 456 j_id, TO_DATE('01/02/2012', 'DD/MM/YYYY') date_1, TO_DATE('29/02/2012', 'DD/MM/YYYY') date_2
            FROM   DUAL
UNION         SELECT 999,          TO_DATE ('01/01/2013', 'DD/MM/YYYY'),     TO_DATE ('31/12/2013', 'DD/MM/YYYY')     FROM dual
;

WITH     filtered_data     AS
(
     SELECT     *
     FROM     table_x
     WHERE     date_1     < TO_DATE ('01/07/2012', 'DD/MM/YYYY')
)
,        cntr          AS
(
     SELECT     LEVEL - 1     AS n
     FROM     (
              SELECT  MAX (date_2 - date_1)     AS max_dif
              FROM    filtered_data
          )
     CONNECT BY     LEVEL <= 1 + max_dif
)
SELECT       f.j_id
,       f.date_1 + c.n
FROM       filtered_data  f
JOIN       cntr              c  ON   c.n  <= f.date_2 - f.date_1
ORDER BY  f.j_id
,            c.n
;

Published by: Frank Kulash, 27 January 2012 10:10
Posted filtering example

Tags: Database

Similar Questions

  • How to extend the range of my Airport Extreme Base Station (802. 11 a, c) using a relay of Airport Express (802.11n).  Airport Utility (V635.2) says that this version does not support the relay.  That is what it is?

    How can I extend the range of my Airport Extreme (802. 11 a, c) using an Airport Express (802.11n) point.  Airport (V635.2) utility does not recognize the Express on its screen?  I have to buy equipment?  I'm on a MacPro OS X 10.10.5.  Thank you.

    AirPort utility that ships with OS X 10.10.5 supports base stations as 802.11ac & 802.11n AirPort. It should be able to configure both of your base stations for a scope (wireless connected base stations) or roaming types (base station connected Ethernet) wireless networks.

    When you initially configure the Wan, it helps to keep the two base stations in the same room. Once configured, you can move the base station that extend to the desired location. The important key is that the final positioning of the station that extends the base must be understood that it's to expand in order to maintain sufficient bandwidth to the station remotely for clients from network connected. Please check the following airport user tip for more details.

  • How to define the range of data to a strict typdef through the control reference

    Hello world

    I'm trying to define the range of data to a strict typdef through the reference of the order, when I do, I get an 'error of property node.

    Is it possible to set the range of the strict typdef.

    Thank you

    Vignesh

    Vignesh1987 wrote:

    I'm trying to define the range of data to a strict typdef through the reference of the order, when I do, I get an 'error of property node.

    Is it possible to set the range of the strict typdef.

    Try to set the original control (type-def) and not its instances... to open the reference of the original type-def command, use 'Open VI reference'.

    Published:

    These properties are not available with STRICT TYPE DEF.

    a. data entry limits: increment property

    b. data entry property of limits: Maximum

    c. property limits: Minimum for the data entry

  • Filter for table data, the range of data obtained and defined 2D

    I produce data of an ultrasonic sensor at 1 K Hz, and there is a lot of data (data points range of 0 to 10). However, in some cases when I know that the data should be about 7 (for example) I get outliers (about 9 and 10). Is it possible to define a filter for data in the defined range.

    I averaged the data to get an average value, and outliers are distorting. In the worst case, my outliers are 30 to 40% of the data generated. I created a filter to sort the data and, taken from the lowest value. I stop the loop when data reaches a value greater then 9. But this seems to take a long time (because the loop checks for each data point and there are 1000s of them).

    Is there a better way to filter data and define a predefined table range to collect?

    I enclose my filter.vi... and a set of samples of my previous data. The ranges of data of 10-8 and would like to have the range 7.5 to 8.5 to consider. The sensor records tension here and the problem can be solved by installing a different type of sensor, but if a filter in LabView can due it, the sensor that we use now is absolute.

    I am in kind of emergency, my design in unfinished because of this problem, if someone can find some time to share some suggestions, I will be grateful.

    Thanks in advance.

    See attachment.  I have incorporated the data you've posted in the vi.  It doesn't seem like any data were less than 8.7 or so, so I modified the scope so it would be a few points on average.  Some games were completely out of reach while the average came back like NaN (not a number) due to a division by zero.

  • How to filter for a range of dates calendar events in OS10

    In earlier versions of BlackBerry, I used blackberry.find.FilterExpression to filter the events calendar for a specific range of dates.

    However for BlackBerry OS10 I scoured the web to find a way to do it. I found:http://developer.blackberry.com/html5/apis/blackberry.pim.calendar.calendarfindoptions.html

    I also googled a lot of other sites, but I am unable to understand how to use CalendarFindOptions to refine the calendar of events of a specific timetable. For example, the current week or the next 7 days.

    I found this code example...
    Function listEvents (limit) {}
    Calendar var = blackberry.pim.calendar;
      var CalendarFindOptions = calendar. CalendarFindOptions;
      var findOptions = {}
    'Sort': [{}
    "fieldName": CalendarFindOptions.SORT_FIELD_SUMMARY.
    'desc': false
    }],
    'detail': CalendarFindOptions.DETAIL_AGENDA,
    'limit': limit
    };

    But unable to find examples how adequately limited by date?
    I'm guessing that something like this:
    'Start': new Date (' January 1, 2013, 13:00 "): CalendarFindOptions.SORT_FIELD_START.
    'end': new Date (' January 1, 2013, 16:00 "): CalendarFindOptions.SORT_FIELD_STOP.

    But it is an assumption and does not work I can find no example of how do

    Any help would be appreciated

    See the example for pimcalendar on Github:

    https://github.com/BlackBerry/BB10-WebWorks-samples/tree/master/pimcalendar

    You can find the JS to set filters of beginning and end starts here:

    https://github.com/BlackBerry/BB10-WebWorks-samples/BLOB/master/pimcalendar/index.html#L107

  • Report with 2 settings of filtering by day and 3 measures for a range of dates

    Hello

    I need to establish a relationship with the following criteria:

    (a) I have 5 settings

    (b) tell of 2 measures of data should be based on a date 01/01/2015

    (c) rest of 3 data measures should be based on a range of dates say 01/01/2015-31/01/2015

    No idea how to achieve this?  If so please help me.

    Thanks in advance

    LonaD

    You cannot filter the reports by using the filter function in the formula in the column?

  • At least a record exists in details that cover the range of dates

    Oracle version:

    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production

    Hi gurus

    I'm stuck with a scenario and your employees need help to solve this problem.

    I have the following table:

    Insertion and table creation

    drop table ident;

    create table ident

    (

    agreement_id number (5),

    ident_pk number (5),

    Date of Cov_effective_date,

    Date of Cov_termination_date

    );

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

    Insert ident

    (

    Select 100,1,to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-31','YYYY-MM-DD')

    Union of all the

    Select 200,2,to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-12-31','YYYY-MM-DD')

    Union of all the

    Select 300,3, to_date ('2013-03-01 ',' YYYY-MM-DD '), double null

    );

    Query on table

    Select * ident;

    Agreement_id ident_pk Cov_effective_date Cov_termination_date

    100113/01/0113/01/31
    200213/01/0113/12/31
    300313/03/01

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

    Drop table ident_dtl;

    create the table ident_dtl

    (

    ident_pk number (5),

    ident_dtl_pk number (5),

    date of effective_date,

    date of termination_date

    );

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

    insert into ident_dtl

    (

    Select 1-ident_pk, 10 ident_dtl_pk, to_date('2013-01-01','YYYY-MM-DD') effective_date, to_date('2013-01-31','YYYY-MM-DD') termination_date of double - to agreement_id = 100

    Union of all the

    Select 1,11,to_date('2013-01-01','YYYY-MM-DD'), to_date('2013-01-30','YYYY-MM-DD') of double - to agreement_id = 100

    Union of all the

    Select 2,12,to_date('2013-01-01','YYYY-MM-DD'), to_date('2013-01-30','YYYY-MM-DD') of double - for agreement_id = 200

    Union of all the

    Select 2.13, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id is 200

    Union of all the

    Select 3.14, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id = 300

    Union of all the

    Select 3.15, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id = 300

    );

    Query on table

    Ident_pk Ident_dtl_pk Effective_date Termination_date

    11013/01/0113/01/31
    11113/01/0113/01/30
    21213/01/0113/01/30
    21313/01/0113/01/15
    31413/01/0113/01/15
    31513/01/0113/01/15


    Result of the will

    Agreement_Id Ident_pk

    200                                        2

    300                                        3

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

    There is a single entry in ident against agreement_id and Ident_pk and if you can see that ident_pk is also present in the child table. My requirement is that at least 1 effective_date and child termination_date table must be match/equal to the parent table that is ident cov_effective_date and cov_termination_date against the same column of Ident_pk.

    for example:

    See the data in Ident_pk = 1, a = cov_effective_date 13/01/01 and its cov_termination_date = 13/01/31 and in the details table against column Ident_pk = 1, you can find that at lease 1 combinaisondes date match against Ident_pk = 1

    If you see Ident_pk = 2, then you can't find all the effective_date and termination_date against its corresponding cov_effective_date and termination_date Ident_pk...

    Same as 3

    -----------

    Summary is that there are date range in the ident against agreement_id and Ident_pk table and at least a range of dates even should be exist in detail table is ident_dtl against Ident_pk and if not then show that agreement_id and Ident_pk .

    I made this task using PL/SQL, but I think that there is a way to do the same task in SQL. Guide and if you have any questions then please let me know. Thank you

    Concerning

    Shu


    Hello

    To be considered as a football game, the same line in ident_dtl must have effective_date and termination_date correspondence?

    If so, a solution is:

    SELECT i.agreement_id

    i.ident_pk

    Ident I have

    LEFT OUTER JOIN ident_dtl d.ident_pk d = i.ident_pk

    AND d.effective_date = i.cov_effective_date

    AND d.termination_date = i.cov_termination_date

    WHERE d.ident_pk IS NULL

    ;

    Another pure SQL approach to such problems is to use an EXISTS subquery.

  • extend the set of data

    Hi all
    Please find the below example scenario where I have to extend the set of data.
    I working on oracle 10g and all by extending the data set, we should exclude weekends. The sample is only for 2 ID, but there may be more than one.
    Thanks for your help.
     
    
    ID                    ST_DT          END_DT          VAL 
    ====               ========         =======        ======== 
    1                  2/2/2011             2/4/2011       4 
    1                  2/4/2011             2/8/2011       5 
    1                  2/8/2011                            6 
    2                  1/28/2011           2/1/2011        2 
    2                  2/1/2011                            8 
    
    ID                    DT             VAL 
    ====                ========      =======        
    1                 2/2/2011           4 
    1                 2/3/2011           4 
    1                 2/4/2011           5 
    1                 2/7/2011           5 
    1                 2/8/2011           6 
    1                 2/9/2011           6 
    2                 1/28/2011          2 
    2                 1/31/2011          2 
    2                 2/1/2011           8 
    2                 2/2/2011           8 
    2                 2/3/2011           8 
    2                 2/4/2011           8 
    2                 2/7/2011           8 
    2                 2/8/2011           8 
    2                 2/9/2011           8 
    
    select 1 as id,to_date('02/02/2011','MM/DD/YYYY') as st_dt,to_date('02/04/2011','MM/DD/YYYY') as end_dt, 4 as val from dual 
    union all 
    select 1 as id,to_date('02/04/2011','MM/DD/YYYY') as st_dt,to_date('02/08/2011','MM/DD/YYYY') as end_dt, 5 as val from dual 
    union all 
    select 1 as id,to_date('02/08/2011','MM/DD/YYYY') as st_dt, null as end_dt, 6 as val from dual 
    union all 
    select 2 as id,to_date('01/28/2011','MM/DD/YYYY') as st_dt,to_date('02/01/2011','MM/DD/YYYY') as end_dt, 2 as val from dual 
    union all 
    select 2 as id,to_date('02/01/2011','MM/DD/YYYY') as st_dt,null as end_dt, 8 as val from dual; 

    Hello

    I guess, when end_dt is NULL, you want to use the current date as end_dt, and the results you have posted are the desired results if the query is executed on February 10, 2011.

    Here's one way:

    WITH     got_n_days     AS
    (
         SELECT     id, st_dt, end_dt, val
         ,     NVL ( end_dt
                  , TRUNC (SYSDATE)
                  ) - st_dt          AS n_days
         FROM     table_x
    --     WHERE     ...     -- If you need any filtering, put it here
    )
    ,     cntr          AS
    (
         SELECT     LEVEL  - 1     AS n
         FROM     (
                   SELECT  MAX (n_days)     AS max_n_days
                   FROM     got_n_days
              )
         CONNECT BY     LEVEL <= max_n_days - 1
    )
    SELECT       d.id
    ,       d.st_dt + c.n          AS dt
    ,       d.val
    FROM       got_n_days     d
    JOIN       cntr          c  ON     c.n     < d.n_days
    WHERE       TO_CHAR ( d.st_dt + c.n
                  , 'DY'
                , 'NLS_DATE_LANGUAGE=ENGLISH'     -- If necessary
                ) NOT IN ('SAT', 'SUN')
    ORDER BY  id
    ,            dt
    ;
    

    Basically, each line of your original table must be repeated n times, where n is the number of days between (included) st_dt and end_dt (not included). The first subquery calculates this number and the main query results by combining your data with a "counter table", NTRC, which contains a line for each value of n that you may need. This 'table' is generated in the second auxiliary request.
    The join produces a line for each day. The WHERE clause eliminates the Saturday and Sunday from these results.

    Thanks for posting the sample data in a useful form. That really helps.

    Published by: Frank Kulash, February 10, 2011 14:29

  • Airport Express does not extend WiFi range

    OK, I posted a long time will cost about an airport older Gen Express not extending my wifi range when implemented to extend (wireless) and connected to a network of Apple (Airport Extreme). No solution, so I gave up.

    Still frustrated by the lack of a strong wifi signal to my back door / Garden (it is a small house!), I bought a new Express and set it up again to extend my current network, placed it on my window sill back room (where I get a pretty good wifi signal on my iPhone and iPad), but about 6 feet of him, the other side of the glass in my garden I get a flicker of 1-2 bars the signal strength that is de-energized intermittently.

    I get no significant (or even vaguely reasonable) increase in force wifi when I approach from the Express, but increase next to the extreme.

    Or should I put either the express until properly (I'm sure I'm) or I am fundamentally misunderstand the term "extend a wireless network. Alternatively, I bought 3 years 2 defective Express apart.

    Can anyone help?

    See you soon.

    You have a handy Mac laptop? If so, we can run tests to understand the current quality of the signal at each location where you want to have a Wi - Fi access. If all goes well, we can find better place to place your Express extension for your goals of networking.

  • How to see the photos in a range of dates?

    Hello, everyone.

    I think that I made a mistake of switching to the Photos to iPhoto.

    I want to do something simple. I want to only look at the pictures of 2015, so I can choose 12 to make a calendar. I searched help and online to find how to do this and I cannot figure out how. Can you do this?

    In iPhoto, you click simply on "in the last 12 months.

    Also, I have thousands of pictures over several years in my library, and when I scroll the Viewer is not pop up with the year that I look like iPhotos. How am I supposed to be able to say what year I watch as I am scrolling?

    This seems to be several steps back in terms of functionality.

    Thank you!

    There are several ways:

    • Create a smart album with the rule "Date is in the range...". "or"occurs in the last 12 months.
    • Or use the view of years of the library: Wile look 'Photos' notice click on the arrows to the right of the buttons on traffic lights to intensify between the Collections and the years.  The years will show you the pictures grouped by years:
  • Search a directory of data and display the data that is within the range of dates

    Hello

    I have a full idrectory of data from overtime, and I think of search in the directory and display the data files for specific dates. I only started this encoding yet but I figure I'll take the brain of some SMEs here labview and start in the right direction. My goal is to go through a comprehensive directory of data taken for a month or MORE csv files and select the data to process and display office files the date of its registration. If I take the data of last week, last month or last minute, it should just treat as an exact or more.

    Please help me get started on the right foot

    End date will be probably greater than the start date, right? So, end date must connect at the entrance to the upper limit. Then wire in the range? to the conditional terminal of a tunnel of conditional indexation.

    Lynn

  • 1 each range interval data retrieval

    Hi guys

    I have this game of number, for example. 12 13 201 243 303 584 674 698 731 745 768 800. So what I want to do is to extract the highest number in each interval of 100. For example, in the range of 0 to 100, 13 will only be extracted from.

    Finally, all the data in the result loop must be an array of 13 243 303 584 698 768 800.

    I tried to use a nested loop and a false true case with table generation, but I couldn't get the setting I want. Please help me on this thank you.

    In addition, each number on the top is accompanied by another number, meanwhile extract the data I have, I'd be the number that goes with it on the next column.

    See you soon

    PX

    This assumes that your table is sorted.

    If you use the rest quotient function between the current value and the following in your table and compare the quotients, you will know if the next value is a new hundred, making it the largest present value number in the current one hundred.

  • New in MapPoint. Can help you with the selection of a range of data?

    Hello

    I just open MapPoint 2013 as import data, select a radius from a given location and export data.  That's all I need of MapPoint to manage but can't seem to find a small tutorial on how to on this subject.

    I tried flying by the seat of my pants, so to speak and have selected a range of 70 minutes, but the output file shows only 96 files when I know that many more within a radius of driving I've selected.  Bugs appear to be associated with zip codes.  For example, in the Excel file there are no addresses (records) but only zip codes and a list indicating the number of organizations within each zip.  I want real organizations in a range of one hour.

    You can ask in the following forum because they are more likely to have relevant experts:

    Highway, streets and Trips, MapPoint .

  • By using diskpart to extend a drive keeps data?

    Hello

    A question of XP diskpart.

    I have a drive (not the system drive) that has 2 partitions D and F of road car. I have unallocated disk F and I want to thank the D drive in the space left by the F drive.

    My question is simple: all data contained in the D - drive extended - kept, drive or is it deleted? I checked the documentation diskpart, but couldn't find anywhere who have confirmed or denied.

    Also, it is important that the drive F, which is not awarded, is on the left of the D drive in the disk management utility? I guess that no - just check.

    Thank you

    M

    If extend you the partition to d, then it should keep your data but will not remove all data on f (which would be nothing since his Unassigned)

  • How to extend the volume of data in the Windows XP machine?

    Victorinox original title: space Partition:

    My C drive is almost full (110 MB only free) but my G, E, H readers have at least 23 GB of free space in each of them. SO can I do anything to divide the sapce. I know that to do something with the start menu. Can u direct me giving the steps.

    I can leave 16 GB free space in each drive and have drive C with 21 more GB of space.

    Hi AnirudhRamesh,

    You can use diskpart.exe to extend a data volume in Windows XP.
    For more information, see this link:

    How to extend a data volume in Windows Server 2003, Windows XP, in Windows 2000 and in Windows Server 2008

    http://support.Microsoft.com/kb/325590

    Note: Before moving to take backup of any important data before making changes to the system.

    Hope the helps of information.

    Please post back and we do know.

Maybe you are looking for

  • SHARED USERS, HOW TO IDENTIFY UNKNOWN

    I HAVE ANYWHERE FROM SEVEN TO TEN USERS SHARED IN THE LEFT COLUMN OF MY FINDER WINDOW. I DON'T RECOGNIZE MOST OF THEM. I'VE BEEN CAPABLE OF SOME ID... AS MY APPLE TV, PHONE, AMAZON FIRE, ETC., BUT IT HAS STILL THREE LISTED PC RUNNING WINDOWS THAT I C

  • How to remove the icon from the finder toolbar

    How can I remove this icon from the finder (far left)? I tried searching for its application to remove, and the command option drag does not seem to work. The application is called 'canon IJ network scanner selector. Thank you

  • GPU upgrade

    Hi I currently have a Pavilion dv4-1155se. I'm a big gamer, and I've gotten to the point where I simply can't play new games more. I am currently using an ATI RADEON HD 3200 graphics card. Is it not possible for me to add a Nvidia GeForce GTX 560 m 5

  • Is there a practice of the Windows Server operating system environment?

    I'm looking to get some practice with the Windows Server operating system (2008 or other).  I came across the downloadable 180 trial period, but I don't mean to create a true server temporarily.  I'm looking to be able to have a completely 'virtual w

  • Sony Xperia z3 liquid damage indicator dual sim

    What color is the LOI when it's wet?