I have this query:
SELECT
[Address]=e.Address,
[LastEmail] =
(
SELECT TOP 1 [Email]
FROM Email innerE
WHERE e.UserID = innerE.UserID
AND innerE.Contact = @emailId
AND (IsSent is null OR isSent = 0)
ORDER BY Timestamp DESC
)
FROM Emails e
This works fine, but now, I realized i’d like to get the entire row containing that lastemail column, if this is possible, any ideas on how it could be done?
You can do this: