【发布时间】:2014-07-02 18:46:11
【问题描述】:
我如何列出在发生页面浏览时平均拥有最多 cmet 的前 10 篇文章。
SELECT TOP 10 a.title as 'articles'
FROM articles a
JOIN website_pageviews b on a.id = b.article_id
JOIN comments c on a.id = c.commented_article_id
GROUP BY a.id
我已经做到了这一点,但我现在有点迷茫 - 我该如何做“平均”部分。
我的表格如下
table: website_pageviews (timestamp, article_id, visitor_id, and a bunch of others)
table: articles (id, title, timestamp, content, author, subject)
table: comments (commented_article_id, user_id, timestamp, text)
我在哪里使用最大值或平均值? 请帮忙...谢谢!
【问题讨论】:
标签: sql select web max average