错误:PostgreSQL中“ from”处或附近的语法错误

时间:2019-07-16 05:47:25

标签: postgresql-9.3

我正在做一些RFM模型,被困在这里:

select "customer_id" as a, rfm_recency*100 + rfm_frequency*10 as rfm_combined
from
(select a, 
       ntile(4) over (order by recency) as rfm_recency,
       ntile(4) over (order by frequency) as rfm_frequency) x
from
(select a,
       max("purchase_date") as recency,
       count(*) as frequency
from "customer") y
  

“ from”处或附近的语法错误

1 个答案:

答案 0 :(得分:0)

我找到了答案:

select "customer_id" as a, rfm_recency*100 + rfm_frequency*10 as rfm_combined
from
(select a, 
       ntile(4) over (order by recency) as rfm_recency,
       ntile(4) over (order by frequency) as rfm_frequency
from
(select a,
       max("purchase_date") as recency,
       count(*) as frequency
from "customer") x)y