All pastes #506606 Raw Edit

Someone

public text v1 · immutable
·published 2007-05-24 02:42 UTC
rendered paste body
SELECT
	a.id,
	a.title,
	a.category_id,
	c.title AS category_title
	COUNT(ac.*) AS num_comments
FROM articles a
INNER JOIN articles_category c ON (a.category_id = c.id)
LEFT JOIN article_comments ac ON (a.id = ac.article_id)
WHERE UNIX_TIMESTAMP(datetime) < (NOW() - (60 * 60 * 24 * 7))
GROUP BY a.id
ORDER BY num_comments DESC, datetime DESC
LIMIT 100