Mi piacerebbe utilizzare la funzione genera serie in redshift, ma non ho avuto successo.Utilizzo della funzione sql generate_series() in redshift
La documentazione di redshift dice che non è supportato. Il seguente codice funziona:
select *
from generate_series(1,10,1)
uscite:
1
2
3
...
10
mi piacerebbe fare lo stesso con le date. Ho provato un certo numero di varianti, tra cui:
select *
from generate_series(date('2008-10-01'),date('2008-10-10 00:00:00'),1)
calci fuori:
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]
cercato anche:
select *
from generate_series('2008-10-01 00:00:00'::timestamp,
'2008-10-10 00:00:00'::timestamp,'1 day')
e ha cercato:
select *
from generate_series(cast('2008-10-01 00:00:00' as datetime),
cast('2008-10-10 00:00:00' as datetime),'1 day')
sia calcio out:
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]
Se non assomiglia Userò questo codice da un altro post:
SELECT to_char(DATE '2008-01-01'
+ (interval '1 month' * generate_series(0,57)), 'YYYY-MM-DD') AS ym
PostgreSQL generate_series() with SQL function as arguments
Eseguire 'SELECT version()' sul database per recuperare la versione di Postgres. –
Per una soluzione alternativa, vedere: http://stackoverflow.com/a/34167753/3019685 – systemjack
Ho postato una soluzione alternativa a una domanda simile qui https://stackoverflow.com/questions/22759980/generate-series-method-fails- in-redshift – AlexYes