Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
SELECT WEEK( `date_posted` ) AS week, COUNT( 1 ) AS aantal FROM `news` GROUP BY week ORDER BY week DESC LIMIT 0 , 10
这不起作用。输出是:
week aantal 52 41 51 56 50 49 49 56 48 62
但是,我们还没有到第 52 周。怎么了?
我认为您需要一个WHERE子句:
WHERE
SELECT WEEK( `date_posted` ) AS week, COUNT( 1 ) AS aantal FROM `news` WHERE `date_posted` >= (curdate() - interval 10 week) GROUP BY week ORDER BY week DESC LIMIT 0 , 10