Sql 关系卡不存在

Sql 关系卡不存在,sql,amazon-web-services,amazon-redshift,periscope,Sql,Amazon Web Services,Amazon Redshift,Periscope,我试图查询和汇总的数据是持卡人的日常交易数据。我试着先每天汇总,然后再累计。我可以按天成功聚合,但当我添加以下行时: sum(custs_spent_at_least_once) over (order by day rows unbounded preceding) as cum_total 我收到错误“关系卡不存在” 我有一个不同的查询,它使用相同的代码行执行类似的操作 这是我的代码,可以按天累计 with spenders as ( select [first_tr

我试图查询和汇总的数据是持卡人的日常交易数据。我试着先每天汇总,然后再累计。我可以按天成功聚合,但当我添加以下行时:

sum(custs_spent_at_least_once) over (order by day rows unbounded preceding) as cum_total
我收到错误“关系卡不存在”

我有一个不同的查询,它使用相同的代码行执行类似的操作

这是我的代码,可以按天累计

with spenders as (  

  select
      [first_trans_date:aggregation] as period, 
      count(member_uuid) as custs_spent_at_least_once
    from
      (
        select distinct member_uuid, min(postdate_and_posttime) as first_trans_date
        from
          (
            (
              select
                card_reference_number, postdate_and_posttime
                , dense_rank() over(partition by card_reference_number order by postdate_and_posttime) as rank
              from
                i2c.posted
              where
                [is_crn_post_launch] and [is_merchant_trans]
              group by card_reference_number, postdate_and_posttime
            )
            as posc
            left join card on card.i2c_ref_id = posc.card_reference_number
          )
      group by member_uuid
      ) 
    group by period 
  order by period desc

)

select 
  period 
  , custs_spent_at_least_once
  , sum(custs_spent_at_least_once) over (order by day rows unbounded preceding) as cum_total
from spenders
order by period desc

您没有列
day
。您可能打算在
期间

select period, custs_spent_at_least_once,
       sum(custs_spent_at_least_once) over (order by period rows unbounded preceding) as running_total
from spenders
order by period desc;

啊。非常感谢。这让我发疯。希望错误代码更具描述性。