Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Oracle:Selecione datas entre intervalos de datas usando SQL


Tente isso.
WITH t (sdt, ldt) AS (SELECT MIN (START_DATE), MAX (END_DATE) FROM MY_DATES)
SELECT *
  FROM (    SELECT sdt + LEVEL - 1 AS dates
              FROM t
        CONNECT BY LEVEL <= ldt - sdt + 1) c
 WHERE EXISTS
          (SELECT 1
             FROM MY_DATES d
            WHERE c.dates BETWEEN START_DATE AND END_DATE);

Demonstração