Skip to content


使用week groupby 时可能出错

SELECT concat(year,lpad(month,2,0),lpad(day,2,0)) as mydate,week(concat(year,lpad(month,2,0),lpad(day,2,0)) ,3) as myweek FROM t_status WHERE concat(year,lpad(month,2,0),lpad(day,2,0)) >=20050606 GROUP BY myweek ORDER BY mydate DESC

当db中记录跨年时,使用week group by 应改成yearweek

SELECT concat(year,lpad(month,2,0),lpad(day,2,0)) as mydate,yearweek(concat(year,lpad(month,2,0),lpad(day,2,0)) ,3) as myweek FROM t_status WHERE concat(year,lpad(month,2,0),lpad(day,2,0)) >=20050606 GROUP BY myweek ORDER BY mydate DESC

Posted in Mysql, 技术.


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.