SQL CTE scope in query
问题 I have tables ChatMessages , ChatGroups and ChatGroupMemberships . A user can be in 0..N groups and in group can be 1..N chat messages. That first message is created once group is initied and it is sort of "alive" ping. I'm optimizing the way I'm reconstructing the list of a user's conversations. That list is pretty standard and you may know it from any social site: | Chat with User X -> [last message in that chat group] | Group chat named ABC -> [same] What I did so far was that I simply