SELECT January.customer_id as Jancust_id,
SUM(payments.payment) as Jan_cust_pmts,
COUNT(DISTINCT January.customer_id) AS Jan_orig_cust,
COUNT(DISTINCT payments.customer_id) as Jan_ret_cust,
AVG(payments.payment) as Cust_life_rev
January.acquisition_source as Jan_source
FROM January_Cohort January
LEFT JOIN telemon_payments_data payments
ON January.customer_id = payments.customer_id
GROUP BY Jan_source
所以上面应该是一个查询,其中January_Cohort是一个已经制作的视图,我想把它加入一个表telemon_payments_data。
我是指错了,还是我不能加入表格和观点?
错误消息是说January_Cohort不是表;我知道,这是一个观点。
答案 0 :(得分:0)
可能会起作用 将视图作为子查询表
SELECT January.customer_id as Jancust_id,
SUM(payments.payment) as Jan_cust_pmts,
COUNT(DISTINCT January.customer_id) AS Jan_orig_cust,
COUNT(DISTINCT payments.customer_id) as Jan_ret_cust,
AVG(payments.payment) as Cust_life_rev
January.acquisition_source as Jan_source
FROM (select * from January_Cohort) January
LEFT JOIN telemon_payments_data payments
ON January.customer_id = payments.customer_id
GROUP BY Jan_source