Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date series generation using pure SELECT - SQL? 3

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
PH
Hello all,

Can a record containing a beginning covered date of say, 2015-06-01 and an ending covered date of 2015-06-05 be generated to become five (5) separate records having individual date of the covered dates using pure SELECT - SQL only? If so, how?

TIA


kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
try this

with dtes as
(
select end_date - start_date diff ,start_date
from
(
select to_date('30-apr-15') end_date, to_date('01-jan-15') start_date
from dual
)
)
SELECT dtes.start_date + LEVEL the_dte
FROM dual,dtes
CONNECT BY LEVEL <= dtes.diff
/


In order to understand recursion, you must first understand recursion.
 
@taupirho,

I like it!

@kilroy,

"Once a king, always a king. But being a knight is more than enough."
This may be an instance where meaning is lost in interpreataion.

This PUN is best understood spoken rather than written as night and knight are pronounced the same...
"Once a king, always a king. But once a night is enough."

This kind of pun is similar in structure to...
"Time flies like an arrow. Fruit flys like a banana."

But in both cases the category of relation switches, resulting in the an irony of a pun, a play on words.

"King" relates to "knight" but switches to "night".
"Time flies like" relates to "Fruit flys like," but the fleeting time category of similarity to an arrow switches to a Fruit fly that is not fleeting but attracted to a banana.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
1 select to_date('06012015','mmddyyyy') + (rownum - 1) the_dt
2 from all_objects
3 where rownum < 6
4* order by 1
>/

THE_DT
---------
01-JUN-15
02-JUN-15
03-JUN-15
04-JUN-15
05-JUN-15


Bill
Lead Application Developer
New York State, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top