select sum(value) as LostValue from ElectroBalance where addr = 257 and getTime>=38563.0 and getTime<=38594.0select sum(value) as LostValue from ElectroBalance where addr = 257 and getTime>=0 and getTime<= 100000getTime为datetime数据类型,前一条语句结果为138,后一条为114,也就是说前一条结果比后一条大,请问为什么?
注:114为正确的答案,因为:
select sum(value) as LostValue from ElectroBalance where addr = 257select sum(value) as LostValue from ElectroBalance where addr = 257 and datediff(d,GetTime ,cast(38563.0 as datetime))<=0 and datediff(d,getTime,cast(38594.0 as datetime))>=0两条语句结果都是114。更奇怪的是,在38563.0和38564.0上都加2,即如下:
select sum(value) as LostValue from ElectroBalance where addr = 257 and getTime>=38565.0 and getTime<= 38596.0
结果也是114!!!
注:114为正确的答案,因为:
select sum(value) as LostValue from ElectroBalance where addr = 257select sum(value) as LostValue from ElectroBalance where addr = 257 and datediff(d,GetTime ,cast(38563.0 as datetime))<=0 and datediff(d,getTime,cast(38594.0 as datetime))>=0两条语句结果都是114。更奇怪的是,在38563.0和38564.0上都加2,即如下:
select sum(value) as LostValue from ElectroBalance where addr = 257 and getTime>=38565.0 and getTime<= 38596.0
结果也是114!!!
解决方案 »
- 视图区创建CFormview后的问题?大家帮忙看一下
- 关于error C2065: 'IHTMLFrameBase2' : undeclared identifier
- 有关文档显示的小问题,大虾帮忙
- CListView视图中如何设置背景图
- 高分请教OPenGL,我有一程序,想旋转一正方形,可看起来只是三角形。
- 大家帮忙啊!!!
- OpenGL函数与范例解析手册.chm//右侧没有字是什么回事。。。。
- MFC 如何在非客户区绘制编辑框 组合框等
- 哪位大大用过张乐MaxEnt最大熵工具包
- 哪位大虾QQ的用户在线是如何实现实时检测的?200分送上
- 用什么函数画点可以用double型得,谢谢
- 推荐! 不错的视频教学下载网站!
----------------------------------------------------------------
从你的结果上看,38594.0-38596.0的时间段存在value为负值的数据
所以在getTime>=38563.0 and getTime<=38594.0范围里的值为138
超出这个范围的时候,负值的数据也被计算进去了,也就变成114了
你可以查看一下你的数据库,查一下是否真的存在value为负值的数据,该数据的时间段是什么