我需要som帮助才能正确列出邮件。 现在邮件列表按日期/时间更正,但显示错误的文本。
SELECT
id,
userid,
sendid,
left(mess,35),
max(xdatum) AS maxtid,
status,
bild,
sendname,
sendinfo
FROM mailbox
WHERE userid='" &Session("userid")& "'
GROUP BY sendid
ORDER BY maxtid desc
解决方案:
最后的文字消息来自Lisa33,09:33
最后的文字信息来自AAAdam,08:22
依旧......
如果我能在eacth Group中获得totmail,那就获得奖励。
最后的文字消息(4)来自Lisa33,09:33
最后一篇文字消息(1)来自AAAdam,08:22
答案 0 :(得分:0)
试试这个,使用subselect获取max xdatum,然后将其连接到主表以获取其他列
SELECT
id,
userid,
sendid,
left(mess,35),
Sub1.maxtid,
status,
bild,
sendname,
sendinfo
FROM mailbox
INNER JOIN
(
SELECT sendid, max(xdatum) AS maxtid
FROM mailbox
WHERE userid='" &Session("userid")& "'
GROUP BY sendid
) Sub1
ON mailbox.sendid = Sub1.sendid
AND mailbox.xdatum = Sub1.maxtid
WHERE userid='" &Session("userid")& "'
ORDER BY maxtid desc