作者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
→ visualPHP:補充 忘了加上 count(id) 08/02 18:20
推 eliang:我知道了,謝謝指點 08/02 21:14