在多个表中发现列错误
Posted
技术标签:
【中文标题】在多个表中发现列错误【英文标题】:Column found in more than one table error 【发布时间】:2019-08-16 19:33:45 【问题描述】:我收到以下错误
编译语句时出错: FAILED: SemanticException Column episodeid 在多个表/子查询中发现 [SQL State=42000, DB Errorcode=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;
【问题讨论】:
在此处限定episodeid
列:count(distinct episodeid)
与表格,cps.episodeid
或a.episodeid
或e.episodeid
列 episovspendcesarean 需要从 group by 子句中删除。
【参考方案1】:
在您的选择列表中,您必须指定您的目标表
select
papid, count(distinct a.episodeid) as epicount,
episovcountcesarean, sum(episovspendcesarean),
count(claimnumber) as claimcount,
sum(allowedamount) as spend
或
select
papid, count(distinct e.episodeid) as epicount,
episovcountcesarean, sum(episovspendcesarean),
count(claimnumber) as claimcount,
sum(allowedamount) as spend
【讨论】:
以上是关于在多个表中发现列错误的主要内容,如果未能解决你的问题,请参考以下文章