我正在尝试加入一个内部查询,该查询的结果由另一个表中的值过滤,因此我可以选择顶部结果并在我的主选择语句中多次使用其中的值,但我得到了错误如下:
无法绑定多部分标识符“TessSCCall.Call_Num”。
到目前为止,请参见下面的代码:
SELECT BestAppointmentOffer AS foo -- I'm using this lots of times in different fields
BestAppointmentOffer AS bar -- I'm using this lots of times in different fields
....
FROM TessSCEmploy
INNER JOIN TessSCCall on TessSCEmploy.Employ_Num = TessSCCall.Call_Employ_Num
INNER JOIN
(
SELECT TOP 1 dbo.Aqua_Midnight(AppointmentStartTime)
AS BestAppointmentOffer, CallNumber
FROM AQWEB.[360Tracking].dbo.AppointmentOffers
WHERE CallNumber = TessSCCall.Call_Num
ORDER BY AppointmentStartTime) AS Appointment
on TessSCCall.Call_Num = Appointment.CallNumber
where ....
我怎样才能让它工作,所以我可以在多个字段的计算中使用我的查询(我目前正在尝试加入)中的值,而不重复它?