求救SQL语句,在线等待
数据表user,两个字段count starttime
count starttime
12 2002-6-01
20 2002-6-02
......
67 2002-6-31
里面有一个月的记录,每天有0至n条记录,现在要按周统计count的和,该怎么做
即(2002年6月份好象有6周吧?)
count week
XX 1
.....
XX 6
问题点数:40、回复次数:7Top
1 楼gzhughie(hughie)回复于 2002-07-01 12:53:18 得分 20
SELECT SUN([COUNT]) AS [COUNT], DATEPART(WEEK,starttime) AS [WEEK],YEAR(starttime) AS [YEAR]
FROM [USER]
GROUP BY DATEPART(WEEK,starttime),YEAR(starttime)Top
2 楼njbudong(jinlingboy)回复于 2002-07-01 12:53:20 得分 5
你可以这样做啊,根据用户的选择周,确定周的开始日期和结束日期,然后检索了。Top
3 楼njbudong(jinlingboy)回复于 2002-07-01 12:53:35 得分 0
你可以这样做啊,根据用户的选择周,确定周的开始日期和结束日期,然后检索了。Top
4 楼gzhughie(hughie)回复于 2002-07-01 12:55:28 得分 0
上面的不严密,应该是
SELECT SUN([COUNT]) AS [COUNT],
DATEPART(WEEK,starttime) AS [WEEK],
MONTH(starttime) AS [MONTH],
YEAR(starttime) AS [YEAR]
FROM [USER]
GROUP BY DATEPART(WEEK,starttime),MONTH(starttime),YEAR(starttime)Top
5 楼CoolSlob()回复于 2002-07-01 12:57:27 得分 15
Select sum(id) from table1
group by datepart(ww, da)
自己替代其中的字段吧~~
Top
6 楼CoolSlob()回复于 2002-07-01 13:00:24 得分 0
你们手脚这么快呀?
我才跟别人聊几句呀:(
Top
7 楼CoolSlob()回复于 2002-07-01 13:00:57 得分 0
你们手脚这么快呀?
我才跟别人聊几句呀:(
Top




