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
So the above is supposed to be a query where January_Cohort is a view that was already made, and I'm wanted to join it to a table telemon_payments_data.
Am I referring to it wrong, or can I not join a table and a view?
The error message is saying January_Cohort is not a table; which I know, it's a view.
may be it will work make view as sub-query table
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.