sql >> Base de Datos >  >> RDS >> Oracle

Oracle:seleccione fechas entre rangos de fechas usando SQL

Prueba esto.

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);

Demostración