generate_series() method fails in Redshift

前端 未结 7 1458
时光说笑
时光说笑 2020-11-27 22:01

When I run the SQL Query:

 select generate_series(0,g)
 from ( select date(date1) - date(date2) as g from mytable ;

It returns an error:

7条回答
  •  無奈伤痛
    2020-11-27 22:33

    This works here (pg-9.3.3) Maybe your issue is just the result of a Redshift-"feature"?

    CREATE TABLE mytable
            ( date1 timestamp
            , date2 timestamp
            );
    INSERT INTO mytable(date1,date2) VALUES
    ( '2014-03-30 12:00:00' , '2014-04-01 12:00:00' );
    
    SELECT  generate_series(0, ss.g) FROM
       ( SELECT date(date2) - date(date1) AS g
         FROM mytable
       ) ss ;
    

提交回复
热议问题