我有这个查询:
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
这很好用,但是现在,我意识到我想获得包含 lastemail 列的整行,如果可能的话,有什么想法可以做到吗?