list of days between dates - oracle sql

I have a number of assessments which cover periods of time.

the attachment shows -

fig 1. the current output of o_assessments table
fig 2. desired output.

I need to be able to list all days which the assessments cover, (ie the days between the start and end date). Hopefully my requirments are clear from the sample data.

Who is Participating?
sdstuberConnect With a Mentor Commented:
yet another method, should be equivalent to previous post, but slightly more compact

SELECT   asm_start_date + COLUMN_VALUE asm_date, asm_type, asm_id
            FROM o_assessments,
                 TABLE(SELECT     COLLECT(LEVEL - 1)
                             FROM DUAL
                       CONNECT BY asm_start_date + LEVEL - 1 <= asm_end_date))
ORDER BY asm_date, asm_type

try this

SELECT     asm_start_date + n asm_date, asm_type, asm_id
      FROM o_assessments,(select level - 1 n from dual connect by level < 100)
      where asm_start_date + n <= asm_end_date
  ORDER BY asm_date, asm_type, asm_id  
adjust the 100 to some number big enough to cover your largest date span (but not grossly over sized)

you could generate with a sub query so it would be an exact fit but that would require an extra hit on your table to generate,  so probably not worth it if you can determine an upper limit on your own.
alternate method,  requires a couple more internal sort operations (use autotrace to confirm) but doesn't require extra IO to the table or need you to guess at a maximum range

alternate method,  requires a couple more sort operations but doesn't require a guess of how many rows you might need

SELECT   asm_start_date + COLUMN_VALUE asm_date, asm_type, asm_id
    FROM (SELECT o_assessments.*,
                 (SELECT     COLLECT(LEVEL - 1)
                        FROM DUAL
                  CONNECT BY asm_start_date + LEVEL - 1 <= asm_end_date)
            FROM o_assessments) x,
ORDER BY asm_date, asm_type
tonMachine100Author Commented:
This is great thanks.

(I'm just about to ask another question which is related to this one - so if you could check this one out too that would be appreciated)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.