今天看到下面的帖子,
表img(id,name,uploadTime,description) ,其中uploadTime是DateTime类型。现在的问题是要求把每个月上传的照片数量显示出来。
比如: 2008年1月 3
2008年2月 5
2008年3月 6
SQL Server:


select convert(varchar,datepart(year,updateTime))+'-'+convert(varchar,datepart(month,updateTime)),count(id)
from img with(nolock)
group by datepart(year,updateTime),datepart(month,updateTime)
自己也写了个oracle的来作个对照,小小不同...


select extract(year from last_upd_date)||'-'||extract(month from last_upd_date) as Year , count(lsid)
from ls_network
group by extract(year from last_upd_date),extract(month from last_upd_date)