簡體   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

列定義不明確。 我想知道是否有在同一天補葯。 第 54 行第 32列定義不明確。 我想知道我的連接是否不正確。 對於 t1,我加入了 3 個不同的表,對於 t2,來自第一個表。 結果應該是 t1 和 t2 的結合

d_member_hq_id沒有以表別名為前綴,如果列名存在於 from 子句中的多個表中,則可能會導致問題。 還有其他列也沒有限定,最好對所有列進行限定以避免此錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM