我需要计算mysql表中的数据数周,如果给定的一周我没有数据,那么计数器值必须等于上一周计数器的值。是否有允许我这样做的查询?我试过下面的查询
SELECT TIMESTAMPDIFF(WEEK,tb.FirstDate,InfoData) AS Week,
count(*) AS TOT
FROM MyTable,
(SELECT InfoData AS FirstData
FROM MyTable
ORDER BY InfoTime LIMIT 1) tb
GROUP BY Week