Querys útiles II.

Generación de rangos de fecha

Fuente: https://stackoverflow.com/questions/418318/generate-a-range-of-dates-using-sql

SELECT TRUNC (SYSDATE - ROWNUM) dt
  FROM DUAL CONNECT BY ROWNUM < 366
SELECT<br>
  (to_date(:p_to_date,\'DD-MM-YYYY\') - level + 1) AS day<br>
FROM<br>
  dual<br>
CONNECT BY LEVEL <= (to_date(:p_to_date,\'DD-MM-YYYY\') - to_date(:p_from_date,\'DD-MM-YYYY\') + 1);
SELECT c1 from dual<br>
  MODEL DIMENSION BY (1 as rn)  MEASURES (sysdate as c1)<br>
  RULES ITERATE (365) <br>
  (c1[ITERATION_NUMBER]=SYSDATE-ITERATION_NUMBER)<br>
order by 1