Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generating separate rows for each month in a date range

dorianpcJul 16 2014 — edited Jul 16 2014

Basically I have one row of data, for example:

ID -   Start_Date -  End_Date

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

XXA   1/23/14        3/12/14

And I want to create one row for each month between the Start_Date and End_Date, for each ID, for example:

ID -  Month -     Year

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

XXA  January   2014

XXA  February  2014

XXA  March       2014

Which is the best and most efficient way of doing this? I was thinking of using a cursor, but once this table is created, I need to join other ones to this one. I am new to oracle, and I am not sure if you can join other tables after you run a cursor and create a temporary table. Any help would be greatly appreciated.

This post has been answered by RogerT on Jul 16 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 13 2014
Added on Jul 16 2014
12 comments
8,414 views