我有下面的查询来获取行数并按周对它们进行分组。它工作得很好。
SELECT
WEEKOFYEAR(searched_on) AS weekno,
COUNT(*) AS num_search,
SUBDATE(searched_on, INTERVAL WEEKDAY(searched_on) DAY), INTERVAL + 0 DAY AS date_of_week,
FROM table
GROUP BY WEEK(DATE_SUB(searched_on, INTERVAL 1 DAY)) ORDER BY weekno ASC
我如何修改它以便只选择最后 5 个结果而不使用ORDER BY weekno DESC LIMIT 5
,以免改变数据的排列方式。谢谢