Skip to content
Advertisement

Can we Apply Group By on two columns in Sql Server 2017?

How to get last message of all users who did chat with UserID 1. I want to apply group by on two feilds. The Database is like:

This is table and My question is:

UserID is stored in MessageCreatorUserID or MessageRecieverUserID

I want to get last message of all users, who did the chat with UserID 1.

Advertisement

Answer

Well, you can use window functions:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement