构建了一个子查询,但在on子句中获取了一个未知列。
SELECT *
FROM FINAL_Professional_SP_2013_BCARE_AllCOUNTS
INNER JOIN
(
SELECT COUNT(FINAL_Professional_SP_2013_BCARE_AllCOUNTS.Phy_PLN_CD), SUM(FINAL_MOP_Professional_SP_2013_BCARE.X12_Cost_High),
Total_Low-SUM(FINAL_MOP_Professional_SP_2013_BCARE.X12_Cost_Low),
Total_High-SUM(FINAL_MOP_Professional_SP_2013_BCARE.X12_Cost_High),
AVG_WITHIN_Fac-SUM(FINAL_MOP_Professional_SP_2013_BCARE.X12_Cost_Ave) FINAL_MOP_Professional_SP_2013_BCARE
FROM FINAL_MOP_Professional_SP_2013_BCARE, FINAL_Professional_SP_2013_BCARE_AllCOUNTS
GROUP BY FINAL_Professional_SP_2013_BCARE_AllCOUNTS.TC_Code, FINAL_Professional_SP_2013_BCARE_AllCOUNTS.Phy_PROV_NO
) a ON
FINAL_Professional_SP_2013_BCARE_AllCOUNTS.Phy_PROV_NO=FINAL_MOP_Professional_SP_2013_BCARE.Phy_PROV_NO
AND FINAL_Professional_SP_2013_BCARE_AllCOUNTS.TC_Code=FINAL_MOP_Professional_SP_2013_BCARE.TC_Code;
获取错误 - 错误代码:1054。'on子句'中的未知列'FINAL_MOP_Professional_SP_2013_BCARE.Phy_PROV_NO'。我已将其更改为a.Phy_PROV_NO',但得到相同的错误。
答案 0 :(得分:2)
我怀疑这是你真正想要的:
SELECT allc.TC_Code, allc.Phy_PROV_NO,
COUNT(allc.Phy_PLN_CD), SUM(bcare.X12_Cost_High),
Total_Low-SUM(bcare.X12_Cost_Low),
Total_High-SUM(bcare.X12_Cost_High),
AVG_WITHIN_Fac-SUM(bcare.X12_Cost_Ave)
FROM FINAL_MOP_Professional_SP_2013_BCARE bcare
JOIN FINAL_Professional_SP_2013_BCARE_AllCOUNTS allc
ON allc.Phy_PROV_NO = bcare.Phy_PROV_NO AND allc.TC_Code = bcare.TC_Code
GROUP BY allc.TC_Code, allc.Phy_PROV_NO
您在子查询外面有子查询的连接条件。