I\'m trying to create a SQL view. How could I select the most recent record from one table leaving others as is. I need to select all records from all tables, which works fine,
I would suggest apply
:
SELECT . . .
FROM ptsweb.tblCustomerInqry i LEFT OUTER JOIN
ptsweb.tblCustomer tc
ON tc.CustomerID = i.CustomerID OUTER APPLY
(SELECT TOP (1) p.*
FROM ptsweb.tblProposal p
WHERE tc.CustomerID = p.CustomerID
ORDER BY p.DateCreated DESC
) p
WHERE i.CustInqDate > '2017-01-01' AND tc.CustomerID = 101568;