1

screenshot error message here

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.

herbacidal
  • 39
  • 6

1 Answers1

0

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
krishn Patel
  • 2,579
  • 1
  • 19
  • 30