select sum(datediff(second,stime,etime)/60.0) from callinfo
where userName='xtcrm' and userid ='010 '
and datediff(day, '2010-10-23 0:00:00',calldate)>=0
and datediff(day,'2010-10-23 0:00:00', calldate)<=0
and pstate = '呼出'
select distinct stime from callinfo因为表中有重复数据 所以在计算总和时候无法准确计算,请教在第一个SQL语句前提下 如何去除重复项stime列有重复 其他没有重复
目前callinfo表中需要计算所使用的秒数总和 而开始时间有重复项 所以无法正确计算一共使用多少秒 请教我这个语句应该怎么写??
where userName='xtcrm' and userid ='010 '
and datediff(day, '2010-10-23 0:00:00',calldate)>=0
and datediff(day,'2010-10-23 0:00:00', calldate)<=0
and pstate = '呼出'
select distinct stime from callinfo因为表中有重复数据 所以在计算总和时候无法准确计算,请教在第一个SQL语句前提下 如何去除重复项stime列有重复 其他没有重复
目前callinfo表中需要计算所使用的秒数总和 而开始时间有重复项 所以无法正确计算一共使用多少秒 请教我这个语句应该怎么写??
1 11 22 2010 呼出 1111 09:01:01 09:02:02
2 12 22 2010 呼出 1111 09:03:55 09:10:05
3 13 22 2010 呼出 1111 09:03:55 09:10:22
and datediff(day,'2010-10-23 0:00:00', calldate)<=0
的意思跟
and datediff(day, '2010-10-23 0:00:00',calldate)=0
的区别是什么?
http://topic.csdn.net/u/20091130/21/fb718680-98ff-4afb-98d8-cff2f8293ed5.html?24281
(SELECT distinct stime,etime FROM callinfo ) AS
callinfo
where userName='xtcrm' and userid ='010 '
and datediff(day, '2010-10-23 0:00:00',calldate)>=0
and datediff(day,'2010-10-23 0:00:00', calldate)<=0
and pstate = '呼出'
--采用最小时间比较,如果stime重复,min值一样的
select sum(datediff(second,min(stime),min(etime))/60.0) from callinfo
where userName='xtcrm' and userid ='010 '
and datediff(day, '2010-10-23 0:00:00',calldate)>=0
and datediff(day,'2010-10-23 0:00:00', calldate)<=0
and pstate = '呼出'
group by customNO,calldate,callphone