1> отлично работает в AWS RedShift:разница в Postgres и красным смещением запроса
rep=# \d repdaily
Table "prod.repdaily"
Column | Type | Modifiers
---------------------------+---------+--------------------
timestamp | integer | not null default 0
rep=# SELECT distinct trunc(TIMESTAMP 'epoch' + ((floor(timestamp/86400))*86400) *INTERVAL '1 second') as Date_New FROM repdaily limit 1;
date_new
------------
2016-06-26
(1 row)
rep=# select version();
version
--------------------------------------------------------------------------------------------------------------------------
PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.1096
(1 row)
rep=#
2> Я попытался запустить тот же запрос, как в 9.5.4 и 8.0.2:
Я не знаю, как чтобы сделать его общим, чтобы мы могли запускать его где угодно.
rep=# \d repdaily
Table "prod.repdaily"
Column | Type | Modifiers
---------------------------+---------+--------------------
timestamp | integer | not null default 0
rep=#
rep=# SELECT distinct trunc(TIMESTAMP 'epoch' + ((floor(timestamp/86400))*86400) *INTERVAL '1 second') as Date_New FROM repdaily limit 1;
ERROR: function trunc(timestamp without time zone) does not exist
LINE 1: SELECT distinct trunc(TIMESTAMP 'epoch' + ((floor(timestamp/...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
rep=#
rep=# select version();
version
----------------------------------------------------------------------------------------------------------
PostgreSQL 9.5.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17), 64-bit
(1 row)
rep=#
rep=# select version();
version
-----------------------------------------------------------------------------------------------------------
PostgreSQL 8.0.2 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
(1 row)
rep=#
Это 'date_trunc()' в Postgres, а не только 'trunc()' –