连接配置单元中的3个表-parseexception在“< eof>”附近有一个无关的输入“\u synthjoin\u expecting”

68bkxrlz  于 2021-06-24  发布在  Hive
关注(0)|答案(1)|浏览(353)

我想加入三张table,
摘要

dept_cd | call_dt |  cust_id | hold_time | talk_time |  work_time | call_cd

电话

cust_id | call_count | agent_length

类别

cust_id | call_type |  call_category |  call_start_dt | agent_cd | agent_cd

这就是我想要的输出表,

输出

call_date |sum(talk_time)| sum(work_time)| sum(hold_time)| dept_cd| sum(call_count)| call_type|call_category| call_start_date

如果我只连接summary和call表,那么代码是有效的,当我添加第三个表时,我接收到parseexception错误
这是我的密码,

select
    SU.call_dt,
    SU.dep_code,
    CG.call_type,
    CG.call_category,
    CG.call_start_dt,
    sum(SU.hold_time) as sum_hold,
    sum(SU.talk_time) as sum_talk,
    sum(SU.work_time) as sum_work,
    sum(CA.call_count)as sum_calls
from summary SU
    inner join 
        (select distinct cust_id, call_count from calls) CA on SU.cust_id = CA.cust_id
    inner join 
        (select call_type,call_category,cust_id,call_start_dt from category) CG on SU.cust_id = CG.cust_id
where 
    CG.call_start_dt between '2019-07-01' and '2019-07-31'
    and SU.call_dt between '2019-07-01' and '2019-07-31'
group by
    SU.call_dt,
    SU.dep_code,
    CG.call_type,
    CG.call_category,
    CG.call_start_dt;

对于使用“sum”的列,我收到以下错误。。
编译语句时出错:
失败:parseexception行1:808外部输入“\u synthjoin\u 4324cda7\u Stack\u time\u”预期)靠近“”行1:918外部输入“\u synthjoin\u 4324cda7\u shold\u time\u”预期)靠近“”行1:1028外部输入“\u synthjoin\u 4324cda7\u swork\u time\u”预期)靠近“”
我怎样才能解决这个问题?任何帮助都将不胜感激。

piztneat

piztneat1#

我认为不需要子查询。这是你想要的吗?

from summary SU inner join 
     (select distinct cust_id, call_count
      from calls
     ) CA
     on SU.cust_id = CA.cust_id inner join 
     from category CG
     on SU.cust_id = CG.cust_id

一个名为 cust_id 在一个叫做 category 是可疑的。我希望 join 更像是 category_id .

相关问题