How to iterate over a date range in PL/SQL

前端 未结 7 1897
梦毁少年i
梦毁少年i 2020-12-29 12:56

I need to write a report that generates summary totals against a table with date ranges for each record.

table data:
option   start_date   end_date
opt1              


        
7条回答
  •  情话喂你
    2020-12-29 13:16

    Here is an answer based on an answer above: It uses a start and end date:

    It lists all of the days of 07/01/2013 to 07/31/2013. Easily adaptable to any date range.

    SELECT to_date('07/01/2013', 'mm/dd/yyyy') + LEVEL - 1 AS today
    FROM dual
    CONNECT BY LEVEL <= to_date('07/31/2013', 'mm/dd/yyyy') - to_date('07/01/2013', 'mm/dd/yyyy') + 1;
    

提交回复
热议问题