简体   繁体   English

列定义不明确

[英]column ambigously defined

with t1 as (
  SELECT *
  from   claim fc
         inner join drug_product d
         on d.drug_id = d.drug_id 
            AND d.id = d.id
         inner join pharmacy pha
         on fc.pharmacy_id = pha.pharmacy_id
            and fcnum = pha.num
),
t2 as (
  Select d_memberid,
         fill_dt,
         num,
         d_drug_id,
         count(distinct device_type) as device_count,
         count(device_type),
         count(distinct claim_ID)as claim_count
  from   t1
  group by
         d_member_id,
         fill_dt,
         num
)
Select   t1.*,
         t2.device_count,
         d.* 
from     t1 
         inner join t2 
         on t1.num = t2.num 
            and t1.fill_dt = t2.fill_dt 
            and t1.d_member_id = t2.d_member_id
         inner join drug_product d 
            on t1.d_drug_id = d.d_drug_id
order by claim_count desc

column ambiguouly defined.列定义不明确。 Im trying to find if there dup drug fill on the same day.我想知道是否有在同一天补药。 line 54 column 32 column ambigously defined.第 54 行第 32列定义不明确。 I wonder if my joins are incorrect.我想知道我的连接是否不正确。 for t1 i join 3 different table for t2 is from the first table.对于 t1,我加入了 3 个不同的表,对于 t2,来自第一个表。 outcome should be a join of the t1 and t2结果应该是 t1 和 t2 的结合

d_member_hq_id is not prefixed by a table alias, and could be causing the problem if the column name exists in more than 1 table in the from clause. d_member_hq_id没有以表别名为前缀,如果列名存在于 from 子句中的多个表中,则可能会导致问题。 There are other columns which are also not qualified, it is a good practice to qualify all columns to avoid this error.还有其他列也没有限定,最好对所有列进行限定以避免此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM