Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @LastChatId INT = (SELECT TOP (1) c.Id FROM Chats AS c
- ORDER BY c.StartDate DESC)
- DECLARE @FirstMessage VARCHAR(200) =
- (
- SELECT TOP (1) m.Content
- FROM Messages AS m
- WHERE m.ChatId = @LastChatId
- ORDER BY m.SentOn
- )
- SELECT c.Title, @FirstMessage AS [Content]
- FROM Chats AS c
- WHERE c.Id = @LastChatId
Advertisement
Add Comment
Please, Sign In to add comment