表字段:日期count_date 时间count_time 数据data现在我想对2008-01-12 11:12:13 到 2008-03-12 15:11:58 之间的data字段求和。该怎样写sql语句呢?
解决方案 »
- SQL Server 2005 Express Edtion的JDBC驱动程序
- 不同的水果品种经过SUM求和以后占总量的百分比SQL语句怎么写,谢谢大家!
- 合并数据库记录的问题
- 我让用户通过Modem拨入公司,访问程序,后台数据库是sql server,现在问题是???
- 怎样写SQL语句创建两个表之间的关系?
- 触发器问题,删除多条记录的时候怎么只触发一次?
- 关于批量插入数据(数据在数组中)
- 能否把一个变量定义数据类型,怎样写
- 不规则分组
- 一个打不开SQL Server 2000中的数据表的问题,急!在线等待......
- 两个表查询,如何让B表中没有的数据以空显示?有例子表,谢谢您
- 模糊搜索多个关键字时,CHARINDEX 与like哪个效率更好?
from tb
where convert(char(10),count_date,120) between '2008-01-12' and '2008-03-12'
and convert(char(8),count_time,114) between '11:12:13' and '15:11:58'
select sum(data) from table1 where count_date+' '+count_time between '2008-01-12 11:12:13' and '2008-03-12 15:11:58'
--假设日期count_date 时间count_time 为字符串型.
select sum(data) from tb where cast(count_date + ' ' + count_time as datetime) between '2008-01-12 11:12:13' and '2008-03-12 15:11:58'
where count_date='2008-01-12' and
(count_time between '11:12:13' and '15:11:58')
select sum(data) from tb where cast(convert(varchar(10),count_date,120) + ' ' + convert(varchar(8),count_time,114) as datetime) between '2008-01-12 11:12:13' and '2008-03-12 15:11:58'
where dt+' '+tm between '2008-03-25 10:54:24.670' and '2008-03-25 22:54:24.670'直接连就行