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

Tags: Database

Similar Questions

  • Use the data from a DataSet as a source for another (the join between the sets of data)

    Hello. I come with a problem, very simple, but which I think is not implemented in the beer Pub.

    In the DataModel, I create a DataSet, providing some data (for example, a string from a web service), and after this, I create another set of data that uses this string as a parameter for a database query. Is this possible? The only link I found between the sets of data is only this concatenation of the main data set.

    Is there a way that I can do? Thank you!

    * [url http://www.java-forums.org/blogs/advanced-java/collection/] Java collection *.

    In Publisher 10 g and sooner you can use a data model to the join and the structure of data from different sources SQL.

    In Publisher, 11g, you can join data sets for which Publisher can 'know' on the data fields. For example. In addition to SQL data sets, you can reach Excel, LDAP, MDX and answers. Web Services, like XML file are data sets that editor does not know the data fields, so unfortunately, no way to join them... I know.

    Also, true that LOVs can either be SQL or data fixed (i.e. the entered values).

    Allowing the Web Service as a source of LOV or a way to define data fields, it's something for us to consider for a future version.

    Mike

  • Is it possible to extend the column title "DATE"?

    Hi, I made a table;

    SQL > SELECT * FROM BookCopy;

    DATEACQUI DATEDESTR BTID BCID
    120 9 9 FEBRUARY 06

    The title means 'DATEACQUIRED' but it is said that "DATEACQUI".

    Anyone know if it is possible to extend the title without using VARCHAR, thank you

    Hello

    In SQL * Plus, you can set the width of the DATE column as you would for a VARCHAR2.

    COLUMN  dateacquired  FORMAT A12
    
    SELECT  SYSDATE  AS dateacquired
    FROM    dual;
    

    product

    DATEACQUIRED
    ------------
    29-JAN-09
    
  • 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.

  • Widget jQuery equivalent to the set of data for CC 20141 dreamweaver spry?

    I built a site earlier with CS4 or CS5. I used spry data sets to make menu items in the tables on the Web site. I did some research and found that spry widgets fired suites CC for any reason whatsoever and replaced with jquery widgets. I'm not 100% sure why adobe does this, but what equivalent of jquery widget that's spry data sets in dreamweaver cm³ 20141?

    Thanks for all your help!

    -Joe

    The closest you will get to this http://www.dmxzone.com/go/21863/html5-data-bindings

  • SQL query for the set of data rows not values

    Hello!

    I use Oracle 10 g (10.2.0.1.0) and I need help to solve this difficult task. I have a huge table with more than 145000 records and I shows you only a sample of it:

    ID TEAMNAME_EN DT TEAMNAME_EN HPROB AM APROB FT
    324813 31/8 / 2012 DEN HAAG GRONINGEN 1.90 3.30 3.10 2
    324823 31/8 / 2012 MAINZ GREUTHER FÜRTH 1.75 3.25 3.65 2
    324805 31/8 / 2012 GAZELEC DIJON 1.60 3.15 4.75 1
    324810 31/8 / 2012 ÖREBRO DJURGÅRDEN 2.80 3.25 2 2.05
    324795 31/8 / 2012 FC KÖLN COTTBUS 1.85 3.20 3.35 2
    324837 31/8 / 2012 PORTLAND WOOD COLORADO RAPIDS 2,00 3.20 2.95 1
    324828 31/8 / 2012 DROGHEDA UNITED, DUNDALK 1.45 3.65 5.25 1
    324827 31/8 / 2012 CORK CITY SHAMROCK ROVERS 3,30 3,80 1.70 2
    324833 31/8 / 2012 BARUERI ASA 2.45 3.20 1-2.30
    324798 31/8 / 2012 GENÇLERBIRLIGI ORDUSPOR'A 2.00 3,10 X 3.00
    324814 31/8 / 2012 ALMERE CITY FC OSS 1,80 3,50 3,20 2
    324830 31/8 / 2012 CRICIÚMA BRAGANTINO 1.25 4.35 1 8.00
    324820 31/8 / 2012 VOLENDAM FC EINDHOVEN 1.80 3.25 3.45 1
    324818 31/8 / 2012 MVV MAASTRICHT TELSTAR 1.40 4.00 X 5.25
    324819 31/8 / 2012 DORDRECHT VEENDAM 1.80 3.25 3.45 1
    324834 31/8 / 2012 CEARÁ GUARATINGUETÁ 1.40 3.85 X 5.50

    If this table consists of
    dates
    teams (hometeam, awayteam)
    numbers for homewin, shoot, awaywin probability
    and the final result as 1, X, 2

    What I want is a sql query that returns to me for each hometeam, awayteam and (if possible in a single line)
    all documents of the hometeam which had the same number of prior probability. For example:
    CEARÁ (last line), I would like to the sql to show me all the records of CEARA who had _1.40 3.85 or 5.50_ in each of the three issues of probability, BUT the problem is that I do want separate lines... I can do so far is to calculate a sum of House probability, probability of drawing, close probability for each team but the same records are calculated again in each game of probability!

    This means if CEARÁ has 1.40-3.85-5.50 in the past it will return me this line only once, and not 3 times (one for each set of probability)

    I hope that I've done my duty,
    Thank you for your time and lights
    N. Saridakis

    Is that what you are looking for:

    select hometeam,
           awayteam,
           hw,
           hd,
           hl
    from  (select hometeam,
                  awayteam,
                  ft,
                  SUM(CASE ft
                      WHEN '1' THEN 1
                      ELSE 0
                      END) OVER (PARTITION BY hometeam) hw,
                  SUM(CASE ft
                      WHEN 'X' THEN 1
                      ELSE 0
                      END) OVER (PARTITION BY hometeam) hd,
                  SUM(CASE ft
                      WHEN '2' THEN 1
                      ELSE 0
                      END) OVER (PARTITION BY hometeam) hl
           from   plays)
    where ft is null
    
  • Writing data to extend the acquisition of data for the sampling rate high file

    These are the tasks that I have to do to take noise measurements:

    (1) take continuous data to USB 6281 Office, in a sample of 500 k (50 k samples at a time) rate.

    (2) save data continuously for 3 to 6 hours in any file (any format is OK but I need to save in a series of files rather than the single file). I want to start writing again file after every 2 min.

    I enclose my VI and pictures of my setup of the task. I can measure and write data to the file continuously for 15 minutes. After that, I see these errors:

    (1) acquisition of equipment can't keep up with the software (something like that, also with a proposal to increase the size of the buffer...)

    (2) memory is full.

    Please help make my VI effective and correct. I suggest to remove him "write in the action file" loop of consumption because it takes a long time to open and close a file in a loop. You can suggest me to open the file outside the loop and write inside the loop. But I want to save my data in the new file, after every 2 min or some samples. If this can be done efficiently without using Scripture in the measurement file then please let me know.

    Thank you in advance.

    This example here is for a single file and a channel, you should be able to loop over that automatically. The background commentary should be the name of the channel, no group namede the name of the channel in the control.

  • Help to calculate the difference between the set of dates

    CASE_NAME         TEST_NAME           TEST_ON_HOLD_DATE        TEST_OFF_HOLD_DATE           Days On Hold (Not actual column in the table)
    
    A   1           01-JAN-12               03-JAN-12          3 
    A   2           01-JAN-12               05-JAN-12          5
    A   3           01-JAN-12            08-JAN-12          8
    A   4           04-JAN-12            10-JAN-12          7
    A   5           13-JAN-12            16-JAN-12          4
                                                                                                                                                -----        
                                                                               27               I actually want  total hold days as 14
    
    B  1             01-FEB-12            03-FEB-12          3
    B  2           02-FEB-12            05-FEB-12          4
    B  3           03-FEB-12            08-FEB-12          6
    B  4           05-FEB-12            10-FEB-12          6
    B  5           13-FEB-12            16-FEB-12          4
                                                                                                                                               -----
                                                                               23              Actual hold days for case B :14 days 
    
    I am trying to calculate actual hold days for each case ,could some one please help me to give me idea to start he issue.
    
    
    
    create table Caris_Life (case_name varchar2(10) ,Test_name varchar2 (10),Test_on_Hold_date date ,test_off_hold_date date);
    
    insert into  Caris_life  (case_name,Test_name,Test_on_Hold_date,test_off_hold_date) values ('A',1,TO_DATE ('01/01/2012','MM/DD/YYYY'),TO_DATE ('01/03/2012','MM/DD/YYYY'));
    
    insert into  Caris_life  (case_name,Test_name,Test_on_Hold_date,test_off_hold_date) values ('A',2,TO_DATE ('01/01/2012','MM/DD/YYYY'),TO_DATE ('01/05/2012','MM/DD/YYYY'));
    
    Insert Into  Caris_Life  (Case_Name,Test_Name,Test_On_Hold_Date,Test_Off_Hold_Date) Values ('A',3,To_Date ('01/01/2012','MM/DD/YYYY'),To_Date ('01/08/2012','MM/DD/YYYY'));
    
    insert into  Caris_life  (case_name,Test_name,Test_on_Hold_date,test_off_hold_date) values ('A',4,TO_DATE ('01/04/2012','MM/DD/YYYY'),TO_DATE ('01/10/2012','MM/DD/YYYY'));
    
    insert into  Caris_life  (case_name,Test_name,Test_on_Hold_date,test_off_hold_date) values ('A',5,TO_DATE ('01/13/2012','MM/DD/YYYY'),TO_DATE ('01/16/2012','MM/DD/YYYY'));
    
    insert into  Caris_life  (case_name,Test_name,Test_on_Hold_date,test_off_hold_date) values ('B',1,TO_DATE ('02/01/2012','MM/DD/YYYY'),TO_DATE ('02/03/2012','MM/DD/YYYY'));
    
    insert into  Caris_life  (case_name,Test_name,Test_on_Hold_date,test_off_hold_date) values ('B',2,TO_DATE ('02/02/2012','MM/DD/YYYY'),TO_DATE ('02/05/2012','MM/DD/YYYY'));
    
    Insert Into  Caris_Life  (Case_Name,Test_Name,Test_On_Hold_Date,Test_Off_Hold_Date) Values ('B',3,To_Date ('02/03/2012','MM/DD/YYYY'),To_Date ('02/08/2012','MM/DD/YYYY'));
    
    insert into  Caris_life  (case_name,Test_name,Test_on_Hold_date,test_off_hold_date) values ('B',4,TO_DATE ('02/05/2012','MM/DD/YYYY'),TO_DATE ('02/10/2012','MM/DD/YYYY'));
    
    insert into  Caris_life  (case_name,Test_name,Test_on_Hold_date,test_off_hold_date) values ('B',5,TO_DATE ('02/13/2012','MM/DD/YYYY'),TO_DATE ('02/16/2012','MM/DD/YYYY'));
    Published by: vijayp on Sep 14, 2012 22:58

    Published by: vijayp on Sep 14, 2012 23:09

    >
    Thank you very much for the idea, I will work with your query to see why he gives different number.
    >
    I think that I have now. Try this

    with q as (
    select case_name, test_name, test_on_hold_date, test_off_hold_date,
           lag(test_off_hold_date, 1, test_on_hold_date - 1) over (partition by case_name
            order by test_on_hold_date) prior_off_hold_date,
           lead(test_on_hold_date, 1, test_off_hold_date + 1) over (partition by case_name
            order by test_on_hold_date) next_on_hold_date
    from Caris_life
    ),
       p as (
    select q.*,
            case when (test_on_hold_date > prior_off_hold_date) -- if this record starts a new date range
              then test_off_hold_date - test_on_hold_date +1       -- then just subtract the dates
              when (test_off_hold_date > prior_off_hold_date)      -- but if this record overlaps the previous one
                 then test_off_hold_date - prior_off_hold_date        -- then adjust this records off date to only count the new days
            else 0 end days
     from q
    )
    select case_name, sum(days) days_held from p group by case_name
    
    CASE_NAME,DAYS_HELD
    A,14
    B,14
    
  • Commas distort the setting of data in page APEX elements

    I have a form with several fields - Px_ITEM1, Px_ITEM2, Px_ITEM3, etc..

    I want to create a new record in which I want to automatically assign the new record with the values of the elements 1, 2 and 3 of the current record.

    I do this with a button which redirects the page to itself, and then each element affect the value in the current record. It works fine as long as there is no comma in one of the elements. If there is a comma in, for example, item1 (for example "MY COMPANY, INC."), then the values after the decimal point (here ' INC') will be placed in item2 and the value set to go in item2 will go into item3, etc..

    How can I treat this problem so that commas do not cause this inaccurate transfer to occur?

    Published by: Doug on April 10, 2012 09:40

    Hi Doug,.

    You can define a calculation of load on page to the inversion to commas. The tricky part will make the initial substitution when the page is redirected. I might try a calculation of page after the presents and see if it works, but I think this may not occur since you make a redirect and not a shipment.

    If you redirect right on the same page it is possible to delete any page clearing cache, and then you won't have to pass the items on the page at all, simply adjust the items that already exist on the load calculations.

    A third option would be to adjust your page to submit instead of redirect, using conditions on any process page on submit that you do not want to run.

    Aaron

  • Set the filter of Date &gt; today


    IR vs Hyperion 9

    I want to filter a results by DATE.  I have a column of date called RenewDate.  I want this field to display always what lies in the future.  To do this, the setting always date field must be set to only show what is greater than today.

    How can I do this?

    It should work. Create a calculated item (called now) defined as

    New Date()

    and another (named filter) defined as

    (new Date (RenewDate)) > now

    Define the filter = 1.  Once you handle issues related to the management of the values NULL and my stupid column names, it should work.

  • Comparing two sets of data in BPEL

    Hey guys,.

    There is a web service that provides (and is the source of) data, and a table that is independent of the service that contains the same data. I am writing a 11g BPEL process to synchronize the data that is returned by the service with the data in the table. I invoke the database and service adapter to receive a data collection and I need to compare two sets of data to see what is on the whole of the service data that is not in the set of data in the table, so that I can insert them into the table. I also need to compare the values of the data sets possible updates of already existing records. I don't know how to do it though. I thought using a java embedded activity to compare the two games. What is the best way to do it? Examples of code would be much appreciated.

    Thank you

    Bill

    Hi, can not use the merge (insert or update) operation in the adapter of database for this use case?

  • Drill/output of the hierarchical chart data?

    I have a set of hierarchical and grouped data that are be drawn. I want the user to be able to go down and drill on the sets of data in the graph. When drilling, setting the dataProvider of the graph to the clicked element's children on works well
    However, I don't see no method of drilling back since the clicked item has no parents. Someone has an idea?

    Quote:
    Posted by: Sreenivas R
    I posted a sample here

    http://flexpearls.blogspot.com/2007/12/displaying-groupingcollectionhierarchic.html

    Wow, this is more or less perfect. I just need to change the effects of more then treat a data series. Thanks a bundle.

    UM... seems I also need a way to detect if your at the top level and prevent you from drilling. Shouldn't be too difficult.

    EDIT: Quite easy, just added another check in the loop from the forest to the top.

    However this method disconnects the data grid table, following problem is advanced. But his closer.

    EDIT: Bah, I need more sleep. Just need to point the hView times the grid and table.

  • Extend the underlying data readers in the analytical unit

    HI - hoping someone can help me.

    We VCOps 5.6 installed and just recently have had an error come that there is less than 10% of free for the zone data. The tech docs suggest data that we wouldn't get enough or more space than we prefer.

    I set some additional LUN but embarassingly I am not enough linux-y to ensure orders for properly extend the good player in this space - can anyone help?

    I guess you run the paralytic.

    You don't need to go to the operating system on the virtual machine to add additional space - just close the vApp, add an additional VMDK to each computer virtual where you need additional space and then restart the vApp.  There is a startup script in the virtual machines that will recognize the new storage and expand space can be used with it.

  • Find the median of a set of data

    I have a table that looks like this:

    Range

    Set of data: range values

    Data set b: range values

    0.00 - 0.99

    35

    67

    1.00 - 1.99

    35

    40

    2.00 - 2.99

    49

    54

    3.00 - 3.99

    41

    45

    4.00 - 4.99

    36

    38

    5.00 - 5.99

    31

    34

    6.00 - 6.99

    22

    29

    7.00 - 7.99

    30

    20

    8.00 - 8.99

    24

    16

    9.00 - 9.99

    16

    11

    10.00 - 10.99

    15

    10

    11.00 - 11.99

    12

    5

    12.00 - 12.99

    11

    1

    13.00 - 13.99

    5

    2

    14.00 - 14.99

    5

    1

    15.00 - 15.99

    2

    0

    16.00 - 16.99

    1

    0

    17.00 - 17.99

    2

    0

    18.00 - 18.99

    1

    0

    How can I find the median interval for each set of data (A and B)?

    Thanks for your help!

    Median and range are two different things from what I remember. Can you please send a link to a Web site that could describe what a "median line"?

    Median is the average of a set of data (even counting data sets usually take the average < average > the values of two intermediate points)

    Range is simply the max - min.

    Jason

  • Cannot set the Airport Extreme to extend the existing network

    Network WiFi of my holiday home is provided by the router from my ISP (Time Warner). I have an Airport Extreme, which used to be configured to provide the WiFi network to another well, and I would use it to extend the existing on the TWC router network.

    I had a lot of trouble to do a factory reset on the Airport Extreme, but I'm sure I managed (by turning on with the pressed reset button) after several attempts. At least the extreme doesn't show signs of the old network, he has provided.

    When I try to set it up in the Airport utility, he wants only to create a new network. If I click on 'Other Options' and select 'Add to an existing network', the next screen is titled "This Airport Extreme will create a network" and prompts to enter a new network name and password. (Specifying the name of the network current generates an error because the network already exists, as I expect for the creation of a new network.)

    Any ideas on how to tweak this Airport Extreme by extending a network?

    TIA,

    Doug

    P.S. I have reviewed plugging extreme in one of the TWC router EtherNet ports and create its own WiFi network (with the advantage of adding support for 5 GHz), but the last time I tried I lost all connectivity; I'm afraid that the ISP network might protect against too broad network, although the glitch may have been a coincidence. If anyone has experience/ideas on this alternative configuration, I might be willing to try again.

    AirPort Extreme would not be able to connect using a wireless connection and to extend the wireless network of the ISP, but if you can connect the AirPort Extreme to the ISP using a permanent router, wired Ethernet cable, then AirPort Extreme could be used to provide broader coverage of wireless in this way signal.

Maybe you are looking for