求 修改一个存储过程...
时间:2011-11-29
来源:互联网
SQL code
SQL code
请问在上面的存储过程中怎么实现??
tb_pr: col1 TimeIn A001 2011-01-21 07:48:03 A002 2011-01-21 07:48:33 A003 2011-01-21 07:49:23 A004 2011-01-21 08:20:30 A005 2011-01-21 08:21:00 A006 2011-01-21 08:22:36 A007 2011-01-21 08:23:22 A008 2011-01-21 08:24:03 //该存储过程的作用是统计 tb_pr中 两个 TimeIn之间的时间差 把所有的时间差再统计(两者之间的标准时间差为 30,如果大于30 如:35 那么统计时间时 就计 5) CREATE PROCEDURE [dbo].[sp_leadTime] @startTime datetime, @endTime datetime AS declare @standardProcessingTime datetime declare @totalLeadTime datetime declare @cur_TimeIn1 datetime declare @cur_TimeIn2 datetime set @standardProcessingTime = '00:00:30' set @totalLeadTime = '00:00:00' set rowcount 1 select @cur_TimeIn1 = TimeIn FROM tb_pr where TimeIn > @startTime and TimeIn < @endTime and Line_ID = 'C' order by TimeIn desc set rowcount 0 declare windingCursor CURSOR for select TimeIn FROM tb_pr where TimeIn > @startTime and TimeIn < @endTime and Line_ID = 'C' order by TimeIn desc Open windingCursor Fetch next from windingCursor into @cur_TimeIn2 While @@FETCH_STATUS = 0 begin if @cur_TimeIn1 <> @cur_TimeIn2 begin set @totalLeadTime = @totalLeadTime + (@cur_TimeIn1 - @cur_TimeIn2 - @standardProcessingTime) end set @cur_TimeIn1 = @cur_TimeIn2 Fetch next from windingCursor into @cur_TimeIn2 end close windingCursor deallocate windingCursor select convert(varchar(8), @totalLeadTime, 108)
SQL code
//现在添加 一个新的表,当在上面存储过程中传入的时间为 这表中时间段时,该时间就不用统计 如上面存储过程传入的时间为 2011-01-21 07:48:03 ,2011-01-21 10:48:03 则统计出来的时间要减去 30分钟(07:50 - 08:20) tb_sys: StopName StartTime EndTime 早 07:50 08:20 中 11:30 12:20 晚 17:50 18:30 夜 12:30 01:30
请问在上面的存储过程中怎么实现??
作者: yikeda 发布时间: 2011-11-29
要是交叉怎么办?
作者: xuam 发布时间: 2011-11-29
vfp9.0
copy tb_pr to tb_prback
alter table tb_prback add column cha n(10)
use tb_prback
go 1
startTimeIn=TimeIn
scan
m.TimeIn=TimeIn
ncha=m.TimeIn-startTimeIn
if ncha<=30
repl cha with ncha
else
repl cha with mod(ncha/30)
endif
endscan
copy tb_pr to tb_prback
alter table tb_prback add column cha n(10)
use tb_prback
go 1
startTimeIn=TimeIn
scan
m.TimeIn=TimeIn
ncha=m.TimeIn-startTimeIn
if ncha<=30
repl cha with ncha
else
repl cha with mod(ncha/30)
endif
endscan
作者: jxjdzwang5555 发布时间: 2011-11-29
就是去掉交叉 的时间差哦...
作者: yikeda 发布时间: 2011-11-29
引用 2 楼 jxjdzwang5555 的回复:
vfp9.0
copy tb_pr to tb_prback
alter table tb_prback add column cha n(10)
use tb_prback
go 1
startTimeIn=TimeIn
scan
m.TimeIn=TimeIn
ncha=m.TimeIn-startTimeIn
if ncha<=30
repl cha wi……
vfp9.0
copy tb_pr to tb_prback
alter table tb_prback add column cha n(10)
use tb_prback
go 1
startTimeIn=TimeIn
scan
m.TimeIn=TimeIn
ncha=m.TimeIn-startTimeIn
if ncha<=30
repl cha wi……
能不能再 写详细点。。。。。。。
谢谢?
作者: yinliaobao 发布时间: 2011-11-29
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28