在多个表中发现列错误

时间:2019-08-16 19:33:45

标签: sql hive

我遇到以下错误

  

编译语句时出错:
  失败:在多个表/子查询中发现了SemanticException列Episodeid [SQL状态= 42000,数据库错误代码= 40000]

任何人都可以帮助我重新配置吗?

谢谢!

这是有问题的代码:

select 
    papid, count(distinct episodeid) as epicount, 
    episovcountcesarean, sum(episovspendcesarean), 
    count(claimnumber) as claimcount, 
    sum(allowedamount) as spend
from
    3pdcoe_tc_dm_eoc_nep_peri.star_output_episodes e
join 
    3pdcoe_tc_dm_eoc_nep_peri.dbo_claimpatientservice cps on cps.episodeidd = e.episodeid
join 
    3pdcoe_tc_dm_eoc_nep_peri.star_output_aggregate a on a.episodeid = e.episodeid
where 
    aggtype = 'Window' and agggroup = 'Trigger'
    and eeany = 0 
    and year(episodeend) = '2016' 
    and episovcountcesarean = 1
group by 
    papid, episovcountcesarean, episovspendcesarean;

1 个答案:

答案 0 :(得分:0)

在选择列表中,您必须指定目标表

select 
  papid, count(distinct a.episodeid) as epicount, 
  episovcountcesarean, sum(episovspendcesarean), 
  count(claimnumber) as claimcount, 
  sum(allowedamount) as spend

OR

select 
  papid, count(distinct e.episodeid) as epicount, 
  episovcountcesarean, sum(episovspendcesarean), 
  count(claimnumber) as claimcount, 
  sum(allowedamount) as spend