日期:2014-05-18  浏览次数:20707 次

如何按每月26日进行数据汇总
各位高手:
有下面一个问题,请帮解决

如表中有如下数据行,
2010-06-26 23:02:00
2010-06-27 23:02:00
2010-06-28 23:02:00
2010-06-29 23:02:00
2010-06-30 23:02:00
2010-07-01 23:02:00
2010-07-02 23:02:00
2010-07-03 23:02:00
2010-07-04 23:02:00
2010-07-05 23:02:00
2010-07-06 23:02:00
2010-07-07 23:02:00
2010-07-08 23:02:00
2010-07-09 23:02:00
2010-07-10 23:02:00
2010-07-11 23:02:00
2010-07-12 23:02:00
2010-07-13 23:02:00
2010-07-14 23:02:00
2010-07-15 23:02:00
2010-07-16 23:02:00
2010-07-17 23:02:00
2010-07-18 23:02:00
2010-07-19 23:02:00
2010-07-20 23:02:00
2010-07-21 23:02:00
2010-07-22 23:02:00
2010-07-23 23:02:00
2010-07-24 23:02:00
2010-07-25 23:02:00
2010-07-26 23:02:00
2010-07-27 23:02:00
2010-07-28 23:02:00
2010-07-29 23:02:00
2010-07-30 23:02:00
2010-07-31 23:02:00
2010-08-01 23:02:00
2010-08-02 23:02:00
2010-08-03 23:02:00
2010-08-04 23:02:00
2010-08-05 23:02:00
2010-08-06 23:02:00
2010-08-07 23:02:00
2010-08-08 23:02:00
2010-08-09 23:02:00
2010-08-10 23:02:00
2010-08-11 23:02:00
2010-08-12 23:02:00
2010-08-13 23:02:00
2010-08-14 23:02:00
2010-08-15 23:02:00
2010-08-16 23:02:00
2010-08-17 23:02:00
2010-08-18 23:02:00
2010-08-19 23:02:00
2010-08-20 23:02:00
2010-08-21 23:02:00
2010-08-22 23:02:00
2010-08-23 23:02:00
2010-08-24 23:02:00
2010-08-25 23:02:00
2010-08-25 17:18:00
2010-08-26 23:02:00
2010-08-27 23:02:00

如何能按每月的26日进行数据汇总,
多谢

------解决方案--------------------
SQL code


--不知道是不是想要的
select count(1)-1, convert(varchar(7),dateadd(d,6,[date]),120)
from [tb] group by  convert(varchar(7),dateadd(d,6,[date]),120)

------解决方案--------------------
SQL code
SELECT CONVERT(DATE,dd),SUM....
FROM [TB]
WHERE DATEPART(dd,dd) = '26'

------解决方案--------------------
..........
26 就已经算下月了...
SQL code
create table tb(dt datetime)
insert into tb select '2010-06-26 23:02:00'
insert into tb select '2010-06-27 23:02:00'
insert into tb select '2010-06-28 23:02:00'
insert into tb select '2010-06-29 23:02:00'
insert into tb select '2010-06-30 23:02:00'
insert into tb select '2010-07-01 23:02:00'
insert into tb select '2010-07-02 23:02:00'
insert into tb select '2010-07-03 23:02:00'
insert into tb select '2010-07-04 23:02:00'
insert into tb select '2010-07-05 23:02:00'
insert into tb select '2010-07-06 23:02:00'
insert into tb select '2010-07-07 23:02:00'
insert into tb select '2010-07-08 23:02:00'
insert into tb select '2010-07-09 23:02:00'
insert into tb select '2010-07-10 23:02:00'
insert into tb select '2010-07-11 23:02:00'
insert into tb select '2010-07-12 23:02:00'
insert into tb select '2010-07-13 23:02:00'
insert into tb select '2010-07-14 23:02:00'
insert into tb select '2010-07-15 23:02:00'
insert into tb select '2010-07-16 23:02:00'
insert into tb select '2010-07-17 23:02:00'
insert into tb select '2010-07-18 23:02:00'
insert into tb select '2010-07-19 23:02:00'
insert into tb select '2010-07-20 23:02:00'
insert into tb select '2010-07-21 23:02:00'
insert into tb select '2010-07-22 23:02:00'
insert into tb select '2010-07-23 23:02:00'
insert into tb select '2010-07-24 23:02:00'
insert into tb select '2010-07-25 23:02:00'
insert into tb select '2010-07-26 23:02:00'
insert into tb select '2010-07-27 23:02:00'
insert into tb select '2010-07-28 23:02:00'
insert into tb select '2010-07-29 23:02:00'
insert into tb select '2010-07-30 23:02:00'
insert into tb select '2010-07-31 23:02:00'
insert into tb select '2010-08-01 23:02:00'
insert into tb select '2010-08-02 23:02:00'
insert into tb select '2010-08-03 23:0