作者visualPHP (brain)
看板Database
标题Re: [SQL ] 请教SQL达人 (有关GROUP BY)
时间Sat Aug 2 18:19:50 2008
1.每周
select * , week(visit_date) as w from table where 1 order by w
先select一个栏位 把日期转成周
week可以转成一年中的第几周 再用这个去群组
2.每月
select *,MONTH(visit_date) as m from table where 1 order by m
同上
3.每年
select * ,year(visit_date) as y from table where 1 order by y
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.164.78.187
1F:→ visualPHP:补充 忘了加上 count(id) 08/02 18:20
2F:推 eliang:我知道了,谢谢指点 08/02 21:14