Extend the data set

Hi all,
Please find the below sample scenario where i have to extend the data set.
I am currently working on oracle 10g and while expanding the data set we should exclude the weekends.The sample is only for 2 ids but there can be more ids.
Thanks for all 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;

Hi,
I assume that, when end_dt is NULL, you want to use today's date as end_dt, and that the results you posted are the results you want if the query is run 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 row in your original table has to be repeated n times, where n is the number of days between st_dt (included) and end_dt (not included). The first sub-query computes that number, and the main query produces the results by joining your data with a " counter table", cntr, that has one row for every value of n that you might need. That "table" is generated in the second sub-query.
The join produces a row for each day. The WHERE clause eliminates the Saturdays and Sundays from those results.
Thanks for posting the sample data in a useful form! That really helps.
Edited by: Frank Kulash on Feb 10, 2011 2:29 PM

Similar Messages

  • Header data come from the Data Set, Issue if Data Set is sorted

    Currently in our Data Set, the 1st line contains unique fields for the HEADER. For example "adress of the user site".
    If we are sorting the Data Set, the 1st line value is empty, so the Header Data is empty.
    What would be the best way to solve this problem:
      - Duplicate on all lines, but we want to avoid this solution to reduce the Data Set Size?
      - Does Crystal Reports fields can have a specific "Set-up" to define that they are for the Header so, it's an unique value?
    Remark: Our Data Set is unique, ie: there is no table link because it's not possible from the database we are extracting values.
    Thanks in advance

    Hi Alexandre
    The best way to display only the header i.e. the uniques line would be to write a formula. Write a formula to extract the line for header and drag this formula field to your report.
    Hope it helps!!
    Regards
    Sourashree

  • I need help in "HOW TO EXTEND THE DATA TYPE SYSTEM"......

    Hi All,
    I need to add new data type like SDO_GEOMETRY in spatial Oracle.
    I don't mean the User-Defined Datatype but new datatype embed in the database.
    I read the Data Cartridge Developer's Guide but it has info how to use more efficiently UDT through indexes.
    Anybody used the “Type System” under Databases and Extensibility Services?
    It might be written in C++ or Java but I do not know how.
    Any hints and help will be appreciated.
    Thanks,

    > In Figure 1-1 Oracle Services, there is a "Type System" as Oracle Services.
    The "Type System" is merely a compartmentalising the data type handling and implementation code/modules in Oracle.
    This covers all types. Oracle native types, user defined types (UDTs), etc.
    Saying that you want to create a new type in the "Type System" is basically saying you want to use the CREATE TYPE SQL command in Oracle.
    > So, I want new_type1 and new_type2 behave like other built-in types, just the way
    SDO_GEOMETRY works in Oracle Spatial Cartridge.
    Not familiar with the SDO_GEOMETRY. Why do you mention this type specifically? What do you want to do similar?
    > I have already done it with user-defined types. Now I need to do this way so that I can
    compare and contrast in terms of speed, space...etc for part of my research.
    Hmm.. I'm not sure what you are trying to compare ito of a UDT and Data Cartridge extensions. It is not one or the other. What research is this if I may ask?
    Simplistically you extend the Type System with a new UDT/ADT. And there you have a new type data can be used in the SQL Engine and the PL/SQL engine. The OCI (Oracle Call Interface) supports such types via the OCI object API calls - which means this new type can also be used from Oracle clients written in Delphi, C++, Java, etc.
    That new type can be a complex type. This type may need specific management code (memory management, context management, internationalisation, etc). To support this you can extend the UDT/ADT further by developing Cartridge Basic Service interfaces for the type - designing and writing management code to, for example, support specific internationalisation requirements when dealing with multibyte character sets.
    You can also extend the UDT/ADT to be custom managed ito indexing, determining query optimisation, computing costs of custom methods/functions/operators on this custom data type. These extensions are done by developing Data Cartridge interfaces for the type.
    Thus I cannot see what you are trying to compare. It is not one layer/interface versus another. These layers exist for all Oracle types (in the Type System). Oracle not only allows you to add to the top layer by adding/defining a new data type. It also allows you to customise (if needed) the layers below it.

  • How to activate a different sub-report for each row in the data set as main report page breaks on each row of data in the main dataset

    I am going to try asking this same question a different way as I have yet to find a working solution to my problem.  I have a main report and then 8 sub reports.  My main report has one data set and returns one row of data per account number.  One
    of the fields in the main data set is called AccountProf.  My main report displays one page per Account number and then calls a different sub report based on that account's AccountProf value.  The sub reports take in the account number as a parameter
    and get multiple rows of data to display that accounts usage formatted differntly for each AccountProf (hence the 8 different sub report.  
    So far I can figure out how to do everything but setting the visibility property of each sub-reports when I have multiple accounts.  If I use the following expression for the visibility property on each sub report, it makes all the applicable sub report
    for all the accounts requested visible at once:
    =IIF(Fields!AccountProf.Value= "USE_PLUS_DMD",False,True)
    *The value in bold USE_PLUS_DMD  is different for each sub report.
    Here is a look at what the main report look like:
    Here is the main reports data set:

    Hi JasonDWilson77,
    According to your description, there is a main report and 8 sub reports in the report, you want to set visibility of sub reports, if no value is passed to the parameter of sub report, the sub report will not be displayed. If that is the case, please refer
    to the following steps:
      1. Create a new parameter named NewAccountNumber, set its data type the same as @AccountNumber, select Allow multiple values, set Visibility to be hidden, then set all available values to default values.
      2. Right-click the first sub report and open Subreport Properties dialog box, click Parameters in left pane, set name to AccountNumber, then click (fx) button, type the expression like below:
    =Parameters! NewAccountNumber(0)
      3. Click Visibility in left pane, select Show or hide based on an expression, then click (fx) button and type the expression like below:
    =IIF(InStr(Join(Parameters! AccountNumber.Value), Parameters!NewAccountNumber.Value(0))>0 , false,true)
      4. Modify parameter of other sub reports like step2.
      5. Set visibility of other sub reports like step3.
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.
    Wendy Fu
    TechNet Community Support

  • Handling Special characters in the data set

    Hi All,
    I am facing an issue in hadling special characters while writing data to a flat file.
    The data fetched in toad query is *44CAÑADO* (with some specail character over N), but when this same data is written in textpad using UTL_FILE.put_line, the data written is converted to *44CAÑADO*.
    Can anyone please help me how to handle these special charatcers so that the same data is written in text file as well.
    Regards,
    Shruti

    To find the database characterset, please see (Character Sets & Conversion - Frequently Asked Questions [ID 227330.1] -- 2. What is the database character set used for and how is it set?)
    For your issue, please see these MOS docs.
    UTL_FILE Adds ^U (Control U) NAK Character At the End of the Line. [ID 604150.1]
    Character set conversion when using UTL_FILE [ID 227531.1]
    NLS_LANG Explained (How does Client-Server Character Conversion Work?) [ID 158577.1] -- 5.8 UTL_FILE is writing / reading incorrect characters.
    Thanks,
    Hussein

  • Sort the data set after quering

    Hi
    I have a grid where I query and load the data.
    Is it possible to filter and show the same data set which I have got in the grid with a check box item.
    Some occasions needs to get input for the said filter from the first row of the grid.
    (Dev Forms Builder (9.0.4.2.0))
    rgds
    shabar

    Hi Navnit Punj/Danish
    I hav a following table
    clo1 col2 col3  col4
    12    po   56    Y
    13    ss   75    Y
    14    ty   40    N
    19    po   35    Y
    21    po   80    NWill say by normal query (F11 and after giving col2 value in the grid and ctrl + F11)I get the following data on the grid
    12    po   56    Y
    19    po   35    Y
    21    po   80    NWith this by clicking check box I want to get the records only having 'Y' for the col4.
    rgds
    shabar

  • I have used a 'for loop' to create an array of output data, however I want the each of the data sets from the array to be placed into a 1-D array. How do I concatenate the output of the for loop into a 1-D array?

    I am using this to create a data set that will be passed as an anolog output therefore it needs to have the correct array dimensions to go into the analog write vi.

    I'm updating my request... I've figured out how to do this by copying an example that uses a simple FOR loop (as seen in the attached current version of my VI). My question now becomes this: Is there a way to save the Y values corresponding to those X values into two more arrays? That is, just for argument's sake, let's say I took the first 100 elements from the X array, and found them to be positive. Then I would like to take the first 100 elements of the Y array and put them into a 'Y Values for X > 0' array. ...And likewise with the negative X values, they should have a separate array of corresponding 'Y values for X < 0' array.
    I can see that I should somehow save the indices of the positive X values from the large arrray wh
    en I sort them out, and use those indices to pick out the elements from the main Y array with the same indices.
    I just can't seem to set up the code necessary to do this. ...Can anyone help, please?
    Attachments:
    Poling_Data_Reader_5i.vi ‏79 KB
    30BLEND.txt ‏3 KB

  • Cannot read the next data row for the data set

    Hi,
    My report runs fine when I view in VS, data shows fine when I run the query in the data window, but when I publish it to the server, I get the above error. I am running SQL server 2005 RTM and I have re-deployed the entire solution.
    Any ideas?

    Hi All,
    Upon investigation found that there was an issue with converting varchar value to datatime datatype in Stored Procedure and that is why report was throwing error.
    I ran same report in BIDS and got clear error message
    An error has occurred during report processing. (rsProcessingAborted)
    Cannot read the next data row for the dataset xxx. (rsErrorReadingNextDataRow)
    The conversion of a varchar datatype to a datetime datatype resulted in an out-of-range value
    Once I corrected this, It is working fine.
    Thanks Shiven:) If Answer is Helpful, Please Vote

  • Show a graph without (or hiding) the data set inside the report

    Hi everybody,
    I created a report very simple with 3 columns:
    1) description
    2) minutes (number)
    3) calculated field (varchar) - where the minutes are transformed in a string which shows weeks, days, hours and minutes
    Then I created a graph, initially based on the minutes (Y axis) and the descriptions (X axis)
    Now, in my report I'd like to see only 2 columns: the description and the calculated field, but if I delete the column 'minutes', also the graph disappears.....
    So, my question is this: Is there a way to hide the minutes column in order to show ONLY the description and the calculated field but at the same time show also the graph (where Y values are always the minutes) ?
    Thanks in advance
    Alex

    Hi Frank,
    thanks for your response.
    I created a fragment-based flow and dragged it onto the main page as a region component. The main page contains the panelAccordian with its showDetailItem's. Each of the showDetailItem components of the panelAccordian contain such a region component.
    Now I set the partial trigger's property of the region component pointing to the showDetailItem component which contains the region but nothing changed. The graph is still not visible at the first click on the detailItem. I also set the trigger's property of the region component pointing to the panelAccordian but also nothing happens.
    Regards
    Michael
    Edited by: user13061309 on 06.08.2010 03:00

  • Please help! Multiple users accessing the same data sets

    Hi all,
    Can anyone provide a bit of insight in to a question I have?
    We have two users that require to see the same set of data in the BPC Excel interface at the same time. The information is employees and date.
    User 1 would like to see All Employee SignedData for 1 month, and User 2 would like to see just a slice of the Employees for 1 month.
    If both of the Users are logged in at the same time, what will happen in terms of SAP 'locking' the data set? I am aware of Data Access Profiles to restrict their access to particular Master Data but there will be the requirement for users to see (maybe just in read-only), data that is shared between both Users.
    Will it throw up an error or can I make it so that users have 'read only' access?
    Any advice would be very much appreciated!
    Nick

    Hi Nick,
    No issue with that at all.
    They can even both have write access. If they try to update the exact same record at the same time BPC will just keep writing Delta records.
    User A enters 10
    User B enters 20
    User A refreshes and will get 20
    User B refreshes and also gets 20

  • Why would only the first line of my data set txt file work?

    Hi -
    I had a lot of success using variables and external data sets until today.
    I have an external text file that I have imported as a data set (Image/Variables/Data Sets/Import...).  All of the variables have been defined and confirmed (at least PSD hasn't told me it can't find something which is the typical error msg.)
    This external text file, with the extension ".txt" has 12 lines on it, each line is 7 comma separated values, and each line is ending in a carriage return.
    YESTERDAY when I used File/Export/Export Data Set as Files... the procedure went beautifully for the 8 times I used it.  TODAY I only get the first of the 12 lines completed and then the export stops.  There are no error messages or other signs that Photoshop has choked on something so I guess something is wrong with my text file... BUT WHAT??
    Any insight on any step in this would be helpful.  You all know that if I'm using this feature it's because I have TONS of repetition ahead of me if it doesn't work.
    TIA your expertise,
    JL

    Fixed it!
    When Exporting as Data sets as files... the step I missed was to select "All Data Sets" from the Data Set drop down.
    Thanks all.
    JL

  • Query - Cannot Retrieve the Data / Result Set

    Hello,
    I'm trying to query a cube through the OLAP connection using Java and every time I try to execute a query an exception is thrown stating "Cannot retrieve the data set" or "Cannot retrieve the result set" depending on how I'm doing the query.  I've tried to execute the query both through the use of an IBIQuery and IBICommandProcessor object as well as directly through the IBIOlap connection via an MDX statement and both methods produce the same exception.  If anyone can shed some light on why exception is being thrown it would be greatly appreciated.

    please help me ... The question has nothing to do with 'getting' data from excel and certainly not with putting it into MySQL.
    The stack trace specifically tells you that your connection string is wrong.
    It also tells you which connection string is wrong.
    Which you can use to determine specifically which one is wrong. And which you did not provide that info to us.

  • How to set the date date type to work

    This may be a silly question, but I can't seem to get the Date data type to work for a date account member. When I go into the Planning app and choose an account that I want to set as a date entry account, the web form doesn't seem to show that the date setting works for the account. I even set my account type to be Saved Assumption. For example, I expect to see the date formatted to 10/20/2009 when I enter that value in the web form under my account "Hire Date". I also checked the display options under the Planning preferences. So does anyone know if this function even works on 9.3 or 11.1?

    Hi,
    Sounds like you have not set the evaluation order for accounts. Administration > Dimensions > Evaluation Order > select plan type > move accounts to the other window, apply.
    Try the form again.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Newbie question about setting the date of a UIDatePicker

    I created a UIDatePicker in my view and called it targetDate.
    If I don't set targetDate's date property, the UIDatePicker shows up by default with a date of November 30, 0002.
    So, when the view loads, I did this:
    NSDate *today = [NSDate date];
    targetDate.date = today;
    (Note: in the above expression, the square brackets around "NSDate date" don't show up and are turning the expression into a link instead.)
    After doing that, when the view loads the UIDatePicker object initially shows the correct month and date, but it shows 0001 as the year.
    So my question is, why doesn't this set the correct year?
    In the Interface Builder the UIDatePicker's minimum and maximum dates are set from 1/1/0001 to 1/1/4001. I don't know if that has anything to do with the problem. I assumed that was just setting the allowed range for picking.
    I don't know what the "Date" setting field in the IB above the minimum date field is supposed to be for either.
    Anyway, am I not setting the date property correctly?
    Thanks,
    doug
    Message was edited by: Doug Lerner2

    Instead of setting the .date property when the view loads I ended setting it when the UIDatePicker is displayed and the date setting works ok now.
    By the by, if you have very early dates set, like January 1, 0001, the dates of the months are off by a few days. I guess that has to do with the whatever happened like 1000 years ago when they made a big adjustment to the calendars.
    doug

  • Variable Data Set has only one thing but the error asks for more

    Hi -
    I have a PSD (CS5, Win7) where I've defines 5 layers with variable names. One of them is the Heading layer with the variable named varHeading.  The Data Set I'm importing is very simple in that only the Heading layer will change. I'm gone over the construction of this text file a number of times but when I try to Import it as a Data Set I get the error:
    "Could not parse the file contents as a data set.  There were not enough variable names in the first line of the text file."
    varHeading
    "BABY CAR SEAT AECC0841"
    "BABY CAR SEAT AECC0842"
    "BABY CAR SEAT AECC0843"
    "BABY CAR SEAT AECC0844"
    "BABY CAR SEAT AECC0845"
    My first question is - does the number of variables stored in the PSD file have to match the variable names in the first line of the text file??
    If NOT - can someone please help me figure out what I'm doing wrong?
    TIA your expert input.
    j2

    When you say you have defined 5 layers with variable names are you trying to attach the data set, that has one column, to each one at the same time? Did you create the data set in the Photoshop Data Sets Dialog ? The error that you are getting pops up when you have defined more variables than you have in your data set.

Maybe you are looking for

  • Using a Pac File with the new Macbook Pros

    I have recently purchased a new Macbook pro and to access the internet at my college, I need to use a Pac File, and My class mate has the drop down option to select it due to their macbook pro is an older model and my new macbook doesn't, how do I ge

  • Best Practice for using UML in JDeveloper 11g

    Hi, We are embarking upon a big program that involves development of a Webcenter 11g based Portal. We will be using JDeveloper for doing the development work. We are investigating whether we can use JDeveloper for doing the design work too. Towards t

  • I need help choosing a monitor! PLEASE HELP!

    I getting a brand new mac mini from ebay and i am deciding between a 15-inch or a 14-inch LCD display. I was just wondering, if both of the displays have a resolution of 1024 x 768, is that the pixel count too? so does that mean the pixels on the 15-

  • Can anyone explain this please...

    I am having a discussion with one of my freind.. and he claims.. Static methods can not be overridden but can be hidden And then one more friend claimed... Static methods can be over ridden by the static methods in the derived calss only Who is right

  • Keyed footage from Premiere Pro CC getting cut in half by AME

    Hello all,    I am having an odd sort of problem.  Anytime I have a sequence from Premiere that includes Keyed footage (UltraKey), the render from AME cuts the keyed subject in half, resulting in a waist - down view.  If I take that same sequence and