+ -
当前位置:首页 → 问答吧 → SQL2008数据段问题

SQL2008数据段问题

时间:2011-12-27

来源:互联网

如果我要查询过去仪器1,6,24小时记录的数据该怎么写,还有任意两个时间点datetime间的数据又该如何写呢
我下面给出一小段代码,请各位大侠帮忙修改下实现以上的要求,谢谢指教……
create proc historydata
@stationid tinyint,
@starttime datetime,
@overtime datetime
as
begin
select Temperature,AirPressure,Humidity,WindDirection,WindSpeed,RainFall,WeatherPhenomenonName,StartTime,OverTime
from SixFactors
join WeatherPhenomenon on WeatherPhenomenon.WeatherNO = SixFactors.WeatherNO
where SixFactors.StationID = @stationid and DATEDIFF(SixFactors.CollectDate,@starttime,@overtime)
go

作者: Yp2800   发布时间: 2011-12-27

自己动手做一下吧,有问题再问

作者: WWWWA   发布时间: 2011-12-27

1,6,24小时记录的数据该怎么写,还有任意两个时间点datetime间的数据又该如何写


select * from tb where rowtime< dateadd(timeclumn,h,-1);
select * from tb where rowtime< dateadd(timeclumn,h,-6);
select * from tb where rowtime< dateadd(timeclumn,h,-24);

select * from tb where rowtime between '2011-12-26 00:00:00' and ''2011-12-27 00:00:00'

作者: rucypli   发布时间: 2011-12-27

自己先分析问题,试着解决,遇到问题再拿出来探讨

作者: TravyLee   发布时间: 2011-12-27

SQL code

,24小时记录的数据该怎么写?
什么意思  是同事查看还是逐个查看 
最好弄个查询后的样式看看

作者: ju523756055   发布时间: 2011-12-27

rowtime是什么意思啊

作者: Yp2800   发布时间: 2011-12-27

引用 2 楼 rucypli 的回复:
1,6,24小时记录的数据该怎么写,还有任意两个时间点datetime间的数据又该如何写


select * from tb where rowtime< dateadd(timeclumn,h,-1);
select * from tb where rowtime< dateadd(timeclumn,h,-6);
select * from tb where rowtime< da……

rowtime是什么呀?

作者: Yp2800   发布时间: 2011-12-27

SQL code
create proc historydata
@stationid tinyint,
@starttime datetime,
@overtime datetime
as
begin
select Temperature,AirPressure,Humidity,WindDirection,WindSpeed,RainFall,WeatherPhenomenonName,StartTime,OverTime
from SixFactors
join WeatherPhenomenon on WeatherPhenomenon.WeatherNO = SixFactors.WeatherNO
where SixFactors.StationID = @stationid and SixFactors.CollectDate BETWEEN @starttime AND @overtime
go

作者: kuqideyupian   发布时间: 2011-12-27

热门下载

更多