# 跪求了，解决方法

ai21940125 2010-10-13 06:24:33

insert into shinian (dtime,dhour,o2,flago2,nox,znox,flagnox,so2,zso2,flagso2,dust,zdust,flagdust,vq,flagvq,t,flagt,p,flagp,vd,flagvd,
pnox,pdust,pso2,h)
select dtime, datepart(hour,dtime),avg(o2),flago2,avg(nox),avg(znox),flagnox,avg(so2),avg(zso2),flagso2,avg(dust),avg(zdust),flagdust,
avg(vq),flagvq,avg(t),flagt,avg(p),flagp,avg(vd),flagvd,avg(pnox),avg(pdust),avg(pso2),avg(h) from 五分钟报表 where dateadd(hour,-1,dtime)<11 and (datepart(month,dtime))=10 and (datepart(day,dtime))=1 and datepart(year,dtime)=2009
group by dtime,o2,flago2,nox,znox,flagnox,so2,zso2,flagso2,dust,zdust,flagdust,vq,flagvq,t,flagt,flagp,vd,flagvd,
pnox,pdust,pso2,h

dtime o2 nox so2 flagso2
2010-6-1 0:00 15.7485733 2732.999774 5212.708246 12
2010-6-1 0:05 15.74220085 2792.895533 5449.833375 12
2010-6-1 0:10 15.75003242 2843.881992 5638.633359 12
2010-6-1 0:15 15.75477791 2758.487783 5629.257168 12
2010-6-1 0:20 15.75609016 2648.922284 5506.954437 12
2010-6-1 0:25 15.75480461 2581.739542 5379.389005 12
2010-6-1 0:30 15.75123787 2485.233948 5242.038514 12
2010-6-1 0:35 15.74884033 2146.705779 4675.418694 12
2010-6-1 0:40 15.75102234 1950.664829 4313.927207 12
2010-6-1 0:45 15.75589752 1985.773374 4322.022007 12
2010-6-1 0:50 15.75708961 2128.957035 4442.065678 12
2010-6-1 0:55 15.758955 2048.108325 4457.949072 12
2010-6-1 1:00 15.7585907 2062.866351 4421.945135 12
2010-6-1 1:05 15.75663376 2175.22369 4557.069564 12
2010-6-1 1:10 15.75714111 2395.008946 4668.886144 12
2010-6-1 1:15 15.75499725 2494.439916 4615.265086 12
2010-6-1 1:20 15.75378609 2623.845259 4814.829707 12
2010-6-1 1:25 15.7511425 2826.638688 5232.841349 12
2010-6-1 1:30 15.74621773 2975.147571 5442.403869 12
2010-6-1 1:35 15.74801826 2751.256528 5188.933726 12
2010-6-1 1:40 15.7506485 2408.471639 4754.324593 12
2010-6-1 1:45 15.75352859 2475.521406 4886.747285 12
2010-6-1 1:50 15.75772667 2649.556054 5121.278271 12
2010-6-1 1:55 15.75942802 2668.882924 5054.419008 12

dtime o2 nox so2 flagso2
2010-6-1 1.00 15.7485733 2732.999774 5212.708246 12
2010-6-1 2.00 15.74220085 2792.895533 5449.833375 12
...全文
93 点赞 收藏 7

7 条回复

2009年10月1日0点到1点的数据,应该第二天的1
``````dateadd(hour,-1,dtime)<11 and (datepart(month,dtime))=10 and (datepart(day,dtime))=1 and datepart(year,dtime)=2009
--那分钟呢！
datepart(hour,dtime)>=0 and datepart(hour,dtime)<=1 and (datepart(month,dtime))=10 and (datepart(day,dtime))=1 and datepart(year,dtime)=2009``````

``datediff(second,'2009-10-1 00:00:00',time)>=0 and datediff(second,'2009-10-1 00:00:00',time)<=3600``

gdk123 2010-10-14

yuhuiwqvb 2010-10-13

SQLCenter 2010-10-13

SQLCenter 2010-10-13

where datepart(hour,dtime)<12

smitxx 2010-10-13
insert into shinian (dtime,dhour,o2,flago2,nox,znox,flagnox,so2,zso2,flagso2,dust,zdust,flagdust,vq,flagvq,t,flagt,p,flagp,vd,flagvd,
pnox,pdust,pso2,h)

2.7w+

MS-SQL Server 应用实例

2010-10-13 06:24