纪念一下,我又开始使用数据库了,拿出数据结账

1.拿出已处理故障单、未处理故障单、满足两小时未到达及4小时未响应

2.分成九组。

3.注意null不能进行算数运算,要用isnull筛除

/*
demand for one of them except applied extensions for faultTicket
  (1.arrivetime more than two hours 2.closetime more than four hours)
*/

/*  1.tackled ticket*/
drop table z01
select FaultBillNo,xqmc,Remark,Type,Address,AddressCode,CreateTime,ArriveTime,CloseTime 
into z01
from T_FaultBill a where (a.CloseTime-a.CreateTime>4 or a.ArriveTime-a.CreateTime>2 or a.RespondTime-a.CreateTime>0.30 ) 
and a.CreateTime between '20190301' and '20190401' 
and a.Delay3Time is null and a.Delay3ingTime is null 
and a.Delay7Time is null and a.Delay7ingTime is null
and a.ArriveTime is not null and a.CloseTime is not null


select a.whgs, b.* from T_Address2 a, z01 b
where a.xqbh=b.AddressCode

/*  2.untackled ticket*/
drop table z002
select FaultBillNo,xqmc,Remark,Type,Address,AddressCode,CreateTime,ArriveTime,CloseTime into z002
from T_FaultBill a where a.CloseTime is null  
and (a.ArriveTime-a.CreateTime>2 or a.RespondTime-a.CreateTime>0.30)
and a.CreateTime between '20190301' and '20190401' 
and a.Delay3Time is null and a.Delay3ingTime is null 
and a.Delay7Time is null and a.Delay7ingTime is null

select * from z002

/*
Z0 was splited into nine groups
*/
select a.whgs, b.* from T_Address2 a, z002 b
where a.xqbh=b.AddressCode

 

 

  • 超过三小时的故障

 

drop table z01

select  FaultBillNo,xqmc,Remark,Type,Address,AddressCode,CreateTime,RespondTime,ArriveTime,CloseTime  into z01

from T_FaultBill a where a.CreateTime between '20190301' and '20190401' 

and  ((datediff(s,a.FaultTime,CloseTime) > 10800 and status = 'close')

or (datediff(s,a.FaultTime,GETDATE()) > 10800 and status <> 'close'))

 

/*

Z01 was splited into nine groups

*/

 

select a.whgs, b.* from T_Address2 a, z01 b where a.xqbh = b.AddressCode

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值