zoukankan      html  css  js  c++  java
  • 大坝安全监测系统预警值上下限设定

    --在大坝安全监测系统中,如果根据历史值设定预警值的上下线,可用以下方法

    SELECT  devicecd ,

            MAX(value) AS max_value ,
            MIN(value) AS min_value
    FROM    [resos_tx].[dbo].[B_Device_R]
    GROUP BY devicecd
    ORDER BY devicecd
     
    --把搜索结果保存为新表 newtable
    --预警值 maxv为历史最大值增加10%,minv为历史最小值减小10%
    --亚安全值上限submaxv和下限subminv 把预警值上下限平均分为三等分 


    UPDATE  B_Device
    SET     B_Device.maxv = newtable.max_value * 1.1 ,
            B_Device.minv = newtable.min_value * 1.1 ,
            B_Device.submaxv = newtable.max_value * 1.1 * 2 / 3
            + newtable.min_value * 1.1 / 3 ,
            B_Device.subminv = newtable.max_value * 1.1 / 3 + newtable.min_value
            * 1.1 * 2 / 3
    FROM    newtable
    WHERE   B_Device.devicecd = newtable.devicecd
            AND B_Device.maxv >= 0
            AND B_Device.minv <= 0 


    UPDATE  B_Device
    SET     B_Device.maxv = newtable.max_value * 1.1 ,
            B_Device.minv = newtable.min_value * 0.9 ,
            B_Device.submaxv = newtable.max_value * 1.1 * 2 / 3
            + newtable.min_value * 0.9 / 3 ,
            B_Device.subminv = newtable.max_value * 1.1 / 3 + newtable.min_value
            * 0.9 * 2 / 3
    FROM    newtable
    WHERE   B_Device.devicecd = newtable.devicecd
            AND B_Device.maxv >= 0
            AND B_Device.minv >= 0 


    UPDATE  B_Device
    SET     B_Device.maxv = newtable.max_value * 0.9 ,
            B_Device.minv = newtable.min_value * 1.1 ,
            B_Device.submaxv = newtable.max_value * 0.9 * 2 / 3
            + newtable.min_value * 1.1 / 3 ,
            B_Device.subminv = newtable.max_value * 0.9 / 3 + newtable.min_value
            * 1.1 * 2 / 3
    FROM    newtable
    WHERE   B_Device.devicecd = newtable.devicecd
            AND B_Device.maxv <= 0
            AND B_Device.minv <= 0 
            
            
    --如果想按照设备编号devicecd分组,再取出每一组按照value排序后的最大3条数据,语句如下
    --目的是为了查看是否有不合理的极值
    SELECT * FROM (
    SELECT  
    SN = ROW_NUMBER() OVER (partition BY devicecd ORDER BY value ), devicecd, value FROM B_device_R) tmp
    WHERE tmp.SN <= 3 order by devicecd
  • 相关阅读:
    改了一下分辨率,Areo特效奇迹般的恢复了...
    此连接需要活动的Internet连接
    Apple Mac OS X每日一技巧026:Spotlight打开文件所在的文件夹
    WP7有约(八):在ListPicker控件的选择页面上播放铃声
    WP7有约(七):实现铃声设置的播放图标的效果
    WP7有约(五):回到主页
    WP7有约:一个应用的破蛋过程
    WP7有约(六):AppBarUtils使用指南
    IE与firefox事件处理
    C#试题
  • 原文地址:https://www.cnblogs.com/zhmhhu/p/5867145.html
Copyright © 2011-2022 走看看