这是我的架构
这是我的查询结果
我如何删除重复项,只是突出显示值,我正在尝试按消息时间排序
WITH CTE AS
(
SELECT c.ContactID, c.Name, m.Text, m.Messagetime,
RN = ROW_NUMBER() OVER (PARTITION BY c.ContactID
ORDER BY m.MessageTime DESC)
FROM dbo.Contacts c
INNER JOIN Messages m ON c.ContactID = m.ContactID
)
SELECT ContactId, Name, Text, Messagetime
FROM CTE
WHERE RN = 1 order by messagetime
我设法获得了预期的结果,但我怎样才能将其转换为在mysql上运行
此致