火灾疏散实时信息系统(演习)

1.用户输入火灾开始时间FireBeginTime,火灾完成时间FireEndTime,逃生统计间隔时间TimeInterval (以秒为单位)

2.report显示累计时间逃生人数(例如:30秒内,60秒内,90秒内....)

3.FireEndTime 若没填,以数据中最后一位逃生时间为准


存储过程:

if exists(select * from sys.objects where name='fire_drill_report')
drop procedure fire_drill_report
GO
create procedure fire_drill_report
 @BeginDate varchar(30),
 @EndDate varchar(30),
 @TimeInterval int
as
while(1=1)
begin
with system_log_1 as
(
 select 
   APPLICATION_ID
  ,SITE
  ,DATE
 FROM SYSTEM_LOG WHERE application_id='VERAPP0005' and Date>=@BeginDate and Date<=@EndDate
),
 group_date as (
select T.groupid,count(T.application_id) as number from
(
 select 
  o.application_id
 ,o.Date
,((datename(hh,o.Date)*60*60+datename(mi,o.Date)*60+datename(ss,o.Date))-(datename(hh,@BeginDate)*60*60+datename(mi,@BeginDate)*60+datename(ss,@BeginDate)))/@TimeInterval as groupid 
  from system_log_1 as o 
) as T
group by T.groupid
--order by groupid
)
select t1.groupid,t1.number,sum(t2.number) as sumNumber
from group_date t1
inner join group_date t2 on t1.groupid>=t2.groupid
group by t1.groupid,t1.number
order by t1.groupid
break
end

---测试

exec fire_drill_report @BeginDate='2015-03-02 10:48:45.000',@EndDate='2015-03-02 23:59:59.000',@TimeInterval=30


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值