我通过Grouping on Customer_number
连接两个表并基于该加载表FROM web.helios_customer_profile cp
JOIN web.helios_order_line ol ON (cp.customer_number = ol.customer_number)
INSERT OVERWRITE TABLE cdm.sa_cdm_customer_sales PARTITION (load_date)
SELECT cp.customer_number, cp.company_name, cp.qualify_score, cp.contract_type, cp.account_status, cp.is_active, cp.sic_code,
cp.email_id, cp.company_size, cp.division_code, cp.company_city, cp.company_state, cp.company_zip, cp.user_id, ol.order_number,
ol.item_number, ol.order_date,
sum(ol.order_quantity) as total_order_quantity,
sum(ol.total_cost_price),
sum(ol.total_sale_price),
(ol.total_sale_price - ol.total_cost_price) as total_profit
where ol.order_date between '2015-09-27' and '2015-10-27'
GROUP BY cp.customer_number;
但是收到错误
" FAILED:SemanticException [错误10002]:第1:30行无效列 参考' company_name'"
答案 0 :(得分:0)
由于它不是声明中的第一列,我会仔细检查列'cp.company_name'
的拼写/实际名称