我试图从表 Jobs 中返回几行,但也从表 JobProducts 中返回下一个截止日期(每个 JobProduct 都有截止日期)。
到目前为止,我有以下内容
SELECT J.CustomerID, J.JobID, J.Status,
J.Deleted, J.JobNo, Customers.CompanyName AS [Company],
J.DateCreated AS [Date Created], derivedtbl_1.DueDate AS [Due Date]
FROM Jobs J
LEFT OUTER JOIN
Customers ON J.CustomerID = Customers.CustomerID CROSS JOIN
(SELECT TOP (1) DueDate, JobProductID, JobID, ProductID, DepartmentID
FROM JobProducts AS JobProducts_1
WHERE JobProducts_1.JobID = J.JobID
ORDER BY DueDate)
AS derivedtbl_1
但我收到错误无法绑定多部分标识符“J.JobID”。
任何帮助将非常感激