0
3 개의 다른 테이블에서 데이터를 가져 오는 SQL 쿼리를 만들려고합니다. 내 생각은 CTE를 사용하여 2 개의 테이블에서 정보를 수집 한 다음 오른쪽 조인을 수행하여 나머지 쿼리에 데이터를 추가하는 것이 었습니다.CTE 다른 ID 필드에 연결
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "V_PhysicianList.Doctor_Number" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "PhysicianFile.Doctor Number" could not be bound.
목표 여기 : 여기
with cte1 as
(
SELECT
[Physician ID] as InternalIdentifier, NPI, [Last Name] as LastName, [First Name]
as
FirstName,
Physician_T1HYCPP.Specialty, DOB, Degree, Department, [State License Number], [UPIN Number],
[Physician Status]
FROM Physician_T1HYCPP left outer JOIN PhysicianFile
on Physician_T1HYCPP.[Physician ID] = PhysicianFile.[TSI MD Number]
where NPI <> ''
),
cteView
AS
(
Select [Doctor_Number], Address, City, State, Zip, Phone, Fax
from V_PhysicianList
)
Select
InternalIdentifier, NPI, LastName, FirstName,
Specialty, DOB, Degree, Department, [State License Number], [UPIN Number],
[Physician Status],
[Doctor_Number],
Address,City, State, Zip, Phone, Fax
from cte1
right outer join cteView on
V_PhysicianList.[Doctor_Number] = PhysicianFile.[Doctor Number]
가 특정 오류입니다 : 나는 여기에 지금까지 작성한 무엇 각 필드에서 서로 다른 데이터를 가져올 필요하지만, 악명 높은 오류
multi-part identifier could not be bound
으로 실행하고 첫 번째 CTE의 2 개 표에서 모든 입력란을 가져 와서 두 번째 CTE의 입력란에 '병합'하여 주소 등이 최종 결과 집합에서 가치를 갖게하는 것입니다. cte1과 cteView의 필드가 올바르게 병합되었는지 어떻게 확인할 수 있습니까?
번호를 포함하여 정확한 오류 메시지를 게시 할 수 있습니까? –
내기를 걸었습니다. 그냥 추가했습니다. – SidC
작은 들여 쓰기는 먼 길을 갈 것입니다 ... – RBarryYoung