【发布时间】:2020-08-19 14:02:37
【问题描述】:
假设在 MySQL 中我有一个表 comments,其中包含字段 post_id, author_id, date 和 comment。
如果我想要每个帖子的第一条评论,我可以这样做
SELECT post_id, author_id, comment, MIN(date) AS comment_date
FROM comments
GROUP BY post_id;
如果我想得到制作cmet最多的作者,我可以做到
SELECT author_id, COUNT(*) AS total_comments
FROM comments
GROUP BY author_id
ORDER BY total_comments DESC;
我想结合这些来回答“哪些作者制作了最多的第一个 cmets?”这个问题。我该怎么做?
【问题讨论】: