0

@wogsland SQL: joining view to table for query is the previous answer.

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

Above is code as corrected with answer from previous ? here on Stack. January_Cohort is a view that I'm connecting to a table telemon_payments_data. It wasn't working previously, and the suggestion was make it a sub-query, but I'm still getting the same error, that January_Cohort doesn't exist as a table. Thoughts?

" #1146 - Table 'telemon_case_study.January_Cohort' doesn't exist"

Is it my GROUP BY?

Community
  • 1
  • 1
herbacidal
  • 39
  • 6
  • Possible duplicate of [MySQL > Table doesn't exist. But it does (or it should)](http://stackoverflow.com/questions/7759170/mysql-table-doesnt-exist-but-it-does-or-it-should) – Siyual Mar 28 '17 at 21:29
  • first thing - the logical order is wrong on the group by and select ... Jan_source – RoMEoMusTDiE Mar 28 '17 at 21:31
  • Possible duplicate of [SQL: joining view to table for query](http://stackoverflow.com/questions/43038500/sql-joining-view-to-table-for-query) – wogsland Mar 28 '17 at 21:33
  • second thing, should be able to join with a view – RoMEoMusTDiE Mar 28 '17 at 21:33

0 Answers0