私はネテザを使用しています。私はマーケティング データ、特にクーポンを扱っています。現在、毎日のクーポン利用者を個別に数えています。大きな問題ではない。ただし、これまでの個別の償還者の数を取得したいと思います。顧客が異なる日に引き換える可能性があるため、1 日の引き換え者の合計だけではないことに注意してください。
私は目を閉じて願い事をし、うまくいくことを願って次のクエリを実行しました。
select redemption_date
,count(distinct(customer_id)) as day_redeemers
,count(distinct(customer_id)) over (partition by null rows unbounded preceding) as cml_redeemers
from coupon_history
group by 1
order by 1
しかし、Netezza は不平を言います: ERROR [HY000] ERROR: Attribute CUSTOMER_ID must be GROUPed or used in an aggregate function
...そして、私は目を閉じて願い事をし、次のことを実行します (group by への追加に注意してください)。
select redemption_date
,count(distinct(customer_id)) as day_redeemers
,count(distinct(customer_id)) over (partition by null rows unbounded preceding) as cml_redeemers
from coupon_history
group by 1,customer_id
order by 1
Netezza は次のように訴えています。
ERROR [HY000] ERROR: DISTINCT aggregate not allowed in window with ORDER BY or frame specification
このエラーにより、内部的に Netezza が遷移をカウントするために customer_id を注文しているのではないかと考えられます。しかし、それは私が次に何を試すべきかについて、ある種の途方に暮れたままにします. シンプルなものを望んでいましたが、どうやら私の幸運な日ではありません。
元のクエリを機能させる方法についてのアイデア、または別のアプローチに関する提案はありますか?
ありがとう!