Re: [SQL ] 請教SQL達人 (有關GROUP BY)

看板Database作者 (brain)時間16年前 (2008/08/02 18:19), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/7 (看更多)
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

08/02 18:20, , 1F
補充 忘了加上 count(id)
08/02 18:20, 1F

08/02 21:14, , 2F
我知道了,謝謝指點
08/02 21:14, 2F
文章代碼(AID): #18b3J7e2 (Database)
討論串 (同標題文章)
文章代碼(AID): #18b3J7e2 (Database)