Amazon Redshift中的amazon-redshift – generate_series函数
栏目: 数据库 · PostgreSQL · 发布时间: 7年前
内容简介:翻译自:https://stackoverflow.com/questions/22554398/generate-series-function-in-amazon-redshift
我试过以下:
SELECT * FROM generate_series(2,4);
generate_series
-----------------
2
3
4
(3 rows)
SELECT * FROM generate_series(5,1,-2);
generate_series
-----------------
5
3
1
(3 rows)
但是当我尝试时,
select * from generate_series('2011-12-31'::timestamp, '2012-12-31'::timestamp, '1 day');
它产生了错误.
06002
我在Redshift 1.0.757上使用PostgreSQL 8.0.2.
知道为什么会这样吗?
Postgres 8.4中添加了支持日期和时间戳的generate_series()版本.
由于Redshift基于Postgres 8.0,您需要使用不同的方式:
select timestamp '2011-12-31 00:00:00' + (i * interval '1 day') from generate_series(1, (date '2012-12-31' - date '2011-12-31')) i;
如果您“只”需要日期,可以缩写为:
select date '2011-12-31' + i from generate_series(1, (date '2012-12-31' - date '2011-12-31')) i;
翻译自:https://stackoverflow.com/questions/22554398/generate-series-function-in-amazon-redshift
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- Python 拓展之特殊函数(lambda 函数,map 函数,filter 函数,reduce 函数)
- Python 函数调用&定义函数&函数参数
- python基础教程:函数,函数,函数,重要的事说三遍
- C++函数中那些不可以被声明为虚函数的函数
- 017.Python函数匿名函数
- 纯函数:函数式编程入门
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Beginning Apache Struts
Arnold Doray / Apress / 2006-02-20 / USD 44.99
Beginning Apache Struts will provide you a working knowledge of Apache Struts 1.2. This book is ideal for you Java programmers who have some JSP familiarity, but little or no prior experience with Ser......一起来看看 《Beginning Apache Struts》 这本书的介绍吧!