以下查询对我来说没问题,但 message_content 列中的内容属于表 al_messages 的第一行。我怎样才能获得最新一行的内容?
SELECT a.CONVERSATION_ID,
a.CREATOR_ID,
c.SCREEN_NAME AS creator_screen_name,
c.FIRST_NAME AS creator_first_name,
c.LAST_NAME AS creator_last_name,
Count(d.MESSAGE_ID) AS messages_count,
MESSAGE_CONTENT
FROM AL_CONVERSATIONS a
INNER JOIN AL_SUBJECTS b
ON a.SUBJECT_ID = b.SUBJECT_ID
INNER JOIN AL_MEMBERS c
ON a.CREATOR_ID = c.MEMBER_ID
INNER JOIN AL_MESSAGES d
ON a.CONVERSATION_ID = d.CONVERSATION_ID
WHERE a.SUBJECT_ID = 301
AND b.CREATOR_ID = 17
GROUP BY a.CONVERSATION_ID
查询结果: