0
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 周。怎么了?

4

1 回答 1

1

我认为您需要一个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
于 2012-11-21T21:55:37.253 回答