SQL:连接要查看的表还是别的什么?

时间:2017-03-28 21:23:54

标签: mysql sql join view group-by

@wogsland SQL: joining view to table for query是之前的答案。

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

以上代码是否已通过之前的回答进行了更正?在堆栈上。 January_Cohort是我正在连接到表telemon_payments_data的视图。它以前没有工作,并且建议是使它成为子查询,但我仍然得到相同的错误,即January_Cohort不作为表存在。 想法?

“#1146 - 表'telemon_case_study.January_Cohort'不存在”

是我的GROUP BY吗?

0 个答案:

没有答案