Usando la función sql generate_series () en redshift
Me gustaría usar la función de generar series en el desplazamiento al rojo, pero no he tenido éxito.
La documentación de desplazamiento al rojo dice que no es compatible. El siguiente código funciona:
select *
from generate_series(1,10,1)
salidas:
1
2
3
...
10
Me gustaría hacer lo mismo con las fechas. He intentado una serie de variaciones, incluyendo:
select *
from generate_series(date('2008-10-01'),date('2008-10-10 00:00:00'),1)
patea hacia fuera
ERROR: function generate_series(date, date, integer) does not exist
Hint: No function matches the given name and argument types.
You may need to add explicit type casts. [SQL State=42883]
También probé:
select *
from generate_series('2008-10-01 00:00:00'::timestamp,
'2008-10-10 00:00:00'::timestamp,'1 day')
Y probado:
select *
from generate_series(cast('2008-10-01 00:00:00' as datetime),
cast('2008-10-10 00:00:00' as datetime),'1 day')
ambos patadas
ERROR: function generate_series(timestamp without time zone, timestamp without time zone, "unknown") does not exist
Hint: No function matches the given name and argument types.
You may need to add explicit type casts. [SQL State=42883]
Si no parece que voy a utilizar este código de otra publicación:
SELECT to_char(DATE '2008-01-01'
+ (interval '1 month' * generate_series(0,57)), 'YYYY-MM-DD') AS ym
PostgreSQL generate_series () con función SQL como argumentos