473,396 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Augmenting a table sorted grouped by month to one grouped by day

6
I have a table with many columns in it. Each row has an ORDER_ID, ORDER_LINE_ID, START_DATE, and END_DATE. The combination of said columns make the row unique. Currently, the row has a start date and end date that is in month intervals. What I need to do is expand the table so that all of the data is still the same, only instead of month intervals it would be days.

For example, one row has
ORDER_ID=1000
ORDER_LINE_ID=1234
START_DATE=11/1/07
END_DATE=12/1/07 (Ranges can be more than one month as well)

I have a DATE column and want to augment the example row into 31 rows (one for each day in the interval; this day would go in the DATE column)

I need some kind of script that would be able to do this for thousands of rows.

How would I go about doing this?

Thanks in advance!
Jan 7 '08 #1
1 1092
amitpatel66
2,367 Expert 2GB
Check this:

Expand|Select|Wrap|Line Numbers
  1. SQL> ed
  2. Wrote file afiedt.buf
  3.  
  4.   1* select ln, sysdate + ln - 1 dt from (select level ln from dual connect by level <= (to_date(sysdate) - to_date(:mydate)))
  5. SQL> /
  6.  
  7.         LN DT
  8. ---------- ----------
  9.          1 08/01/2008
  10.          2 09/01/2008
  11.          3 10/01/2008
  12.          4 11/01/2008
  13.          5 12/01/2008
  14.          6 13/01/2008
  15.          7 14/01/2008
  16.          8 15/01/2008
  17.          9 16/01/2008
  18.         10 17/01/2008
  19.         11 18/01/2008
  20.  
  21.         LN DT
  22. ---------- ----------
  23.         12 19/01/2008
  24.         13 20/01/2008
  25.         14 21/01/2008
  26.         15 22/01/2008
  27.         16 23/01/2008
  28.         17 24/01/2008
  29.         18 25/01/2008
  30.         19 26/01/2008
  31.         20 27/01/2008
  32.         21 28/01/2008
  33.         22 29/01/2008
  34.  
  35.         LN DT
  36. ---------- ----------
  37.         23 30/01/2008
  38.         24 31/01/2008
  39.         25 01/02/2008
  40.         26 02/02/2008
  41.         27 03/02/2008
  42.         28 04/02/2008
  43.         29 05/02/2008
  44.         30 06/02/2008
  45.         31 07/02/2008
  46.         32 08/02/2008
  47.         33 09/02/2008
  48.  
  49.         LN DT
  50. ---------- ----------
  51.         34 10/02/2008
  52.         35 11/02/2008
  53.         36 12/02/2008
  54.         37 13/02/2008
  55.         38 14/02/2008
  56.  
  57. 38 rows selected.
  58.  
  59. SQL> print :mydat
  60.  
  61. MYDAT
  62. --------------------------------------------------------------------------------
  63. 01/12/2007
  64.  
  65.  
I have taken the difference of two dates and displayed the dates (sysdate + ln) between that range. Use this logic and implement your requirement. Let me know in caseof any issues.
Jan 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ken Fine | last post by:
Using ASP, I want to display a series of records grouped by nested years and months, e.g.: 2004 December Record1 Record2 Record3 November Record4
8
by: kaosyeti | last post by:
i have a (hopefully) small problem. i have created a system where a user enters customer information into a table through a form. this table has no primary key. there are 9 fields on the form to...
5
by: JayDawg | last post by:
Is there any way to create a pivot table in a report? I have a query with the fields Date, Name, and Data, and I am trying to create a report that has the dates running across the top (like...
12
by: Orchid | last post by:
Hello all, I have different version of reports which used for different months. For example, I am using report version 1 up to September, but we have some design changes on the report for October,...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
5
by: joshua.nicholes | last post by:
I have an access database that consists of two tables.A data collection table and a species list table. The data collection table has about 1500 records in it and the species list has about 600....
0
by: Oonz | last post by:
Hi friends, please help me in sorting this table. the table should be sorted based on LASTNAME, and then the ID (only non-zero id should be sorted). ID LASTNAME...
8
by: nico3334 | last post by:
I have a database that has a Date column (1/1/2007) and a Data column that has numerical data. I am currently running a query to sum the Data column for a certain month and grouped by day (There is...
2
by: Crazineko | last post by:
Hello all, I am fairly new to Access and am running into a problem. I am looking at a table that has all phone numbers that have called our business for the month of November. However, many of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.